Skip to content

Commit 68e08d4

Browse files
committed
WIP add reward resource
1 parent b263b64 commit 68e08d4

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

lib/cirro_io/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
require 'cirro_io/client/gig_result'
1515
require 'cirro_io/client/gig_time_activity'
1616
require 'cirro_io/client/gig'
17+
require 'cirro_io/client/reward'
1718

1819
module CirroIO
1920
module Client

lib/cirro_io/client/reward.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module CirroIO
2+
module Client
3+
class Reward < Base
4+
has_one :app_worker
5+
end
6+
end
7+
end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
RSpec.describe CirroIO::Client::Reward do
2+
describe 'create' do
3+
before do
4+
configure_api_client
5+
end
6+
7+
let(:app_worker) { CirroIO::Client::AppWorker.load(id: 1) }
8+
9+
it 'creates a reward for an app worker' do
10+
request_url = "#{test_site}/v1/rewards"
11+
stub_request(:post, request_url)
12+
# .to_return(body: File.read('./spec/fixtures/app_worker.json'), headers: { 'Content-Type' => 'application/json' })
13+
14+
request_body = {
15+
data: {
16+
type: 'rewards',
17+
relationships: {
18+
'app-worker': {
19+
data: {
20+
type: 'app-workers',
21+
id: 1
22+
}
23+
}
24+
},
25+
attributes: {
26+
title: 'Title',
27+
description: 'Description',
28+
'billing-date': Date.today.to_s,
29+
amount: 100
30+
}
31+
}
32+
}
33+
34+
described_class.create(title: 'Title', description: 'Description', billing_date: Date.today.to_s, amount: 100, app_worker: app_worker)
35+
36+
expect(a_request(:post, request_url).with(body: request_body.to_json)).to have_been_made
37+
# stub_request(:get, "#{test_site}/v1/app-users/4")
38+
# .to_return(body: File.read('./spec/fixtures/app_user.json'), headers: { 'Content-Type' => 'application/json' })
39+
#
40+
# app_worker = described_class.new
41+
# app_worker.app_user = CirroIO::Client::AppUser.find(4).first
42+
# app_worker.worker_document = {}
43+
#
44+
# app_worker.save
45+
#
46+
# expect(app_worker).to be_valid
47+
# expect(app_worker.id).to eq('1')
48+
end
49+
end
50+
end

0 commit comments

Comments
 (0)