Skip to content

Commit 981e8ec

Browse files
committed
Add reward resource & bump version to 1.5.0
1 parent 4907ad5 commit 981e8ec

File tree

4 files changed

+51
-30
lines changed

4 files changed

+51
-30
lines changed

Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cirro-ruby-client (1.4.0)
4+
cirro-ruby-client (1.5.0)
55
faraday (< 1.2.0)
66
faraday_middleware
77
json_api_client (>= 1.10.0)
@@ -10,9 +10,9 @@ PATH
1010
GEM
1111
remote: https://rubygems.org/
1212
specs:
13-
activemodel (6.1.1)
14-
activesupport (= 6.1.1)
15-
activesupport (6.1.1)
13+
activemodel (6.1.3.2)
14+
activesupport (= 6.1.3.2)
15+
activesupport (6.1.3.2)
1616
concurrent-ruby (~> 1.0, >= 1.0.2)
1717
i18n (>= 1.6, < 2)
1818
minitest (>= 5.1)
@@ -42,9 +42,9 @@ GEM
4242
faraday (>= 0.15.2, < 1.2.0)
4343
faraday_middleware (>= 0.9.0, < 1.2.0)
4444
rack (>= 0.2)
45-
jwt (2.2.2)
45+
jwt (2.2.3)
4646
method_source (1.0.0)
47-
minitest (5.14.3)
47+
minitest (5.14.4)
4848
multipart-post (2.1.1)
4949
parallel (1.19.2)
5050
parser (2.7.2.0)

lib/cirro_io/client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rubocop:disable Style/MutableConstant
22
module CirroIO
33
module Client
4-
VERSION = '1.4.0'
4+
VERSION = '1.5.0'
55
end
66
end
77
# rubocop:enable Style/MutableConstant

spec/cirro_io/client/reward_spec.rb

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
end
66

77
let(:app_worker) { CirroIO::Client::AppWorker.load(id: 1) }
8+
let(:attributes) do
9+
{
10+
title: Faker::Hipster.sentence,
11+
description: Faker::Hipster.paragraph,
12+
'billing-date': Date.today.to_s,
13+
amount: 100,
14+
}
15+
end
816

917
it 'creates a reward for an app worker' do
1018
request_url = "#{test_site}/v1/rewards"
1119
stub_request(:post, request_url)
12-
# .to_return(body: File.read('./spec/fixtures/app_worker.json'), headers: { 'Content-Type' => 'application/json' })
20+
.to_return(body: File.read('./spec/fixtures/reward.json'), headers: { 'Content-Type' => 'application/json' })
1321

1422
request_body = {
1523
data: {
@@ -18,33 +26,19 @@
1826
'app-worker': {
1927
data: {
2028
type: 'app-workers',
21-
id: 1
22-
}
23-
}
29+
id: 1,
30+
},
31+
},
2432
},
25-
attributes: {
26-
title: 'Title',
27-
description: 'Description',
28-
'billing-date': Date.today.to_s,
29-
amount: 100
30-
}
31-
}
33+
attributes: attributes,
34+
},
3235
}
3336

34-
described_class.create(title: 'Title', description: 'Description', billing_date: Date.today.to_s, amount: 100, app_worker: app_worker)
37+
reward = described_class.create(**attributes.merge(app_worker: app_worker))
3538

3639
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')
40+
expect(reward).to be_valid
41+
expect(reward.id).to eq('1')
4842
end
4943
end
5044
end

spec/fixtures/reward.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"data": {
3+
"id": "1",
4+
"type": "bonus-payouts",
5+
"attributes": {
6+
"amount": 8969,
7+
"title": "The Soldier's Art",
8+
"description": "Something",
9+
"billing-date": "2021-06-25",
10+
"external-customer-id": null
11+
},
12+
"relationships": {
13+
"app-worker": {
14+
"data": {
15+
"type": "app-workers",
16+
"id": "52"
17+
}
18+
},
19+
"reference": {
20+
"data": {
21+
"type": "gigs",
22+
"id": "40"
23+
}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)