Skip to content

Commit 08b55d7

Browse files
authored
gig invitation (#6)
1 parent 049d77f commit 08b55d7

File tree

8 files changed

+87
-3
lines changed

8 files changed

+87
-3
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cirro-ruby-client (0.1.3)
4+
cirro-ruby-client (1.0.1)
55
json_api_client
66
jwt
77

lib/cirro_io/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'cirro_io/client/response_debugging_middleware'
55
require 'cirro_io/client/jwt_authentication'
66
require 'cirro_io/client/base'
7+
require 'cirro_io/client/gig_invitation'
78
require 'cirro_io/client/app_user'
89
require 'cirro_io/client/app_worker'
910

lib/cirro_io/client/app_worker.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module CirroIO
22
module Client
33
class AppWorker < Base
44
has_one :app_user
5+
has_many :gig_invitations
56

67
def self.resource_name
78
'app-workers'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module CirroIO
2+
module Client
3+
class GigInvitation < Base
4+
def self.resource_name
5+
'gig-invitations'
6+
end
7+
end
8+
end
9+
end

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.0.0'
4+
VERSION = '1.0.1'
55
end
66
end
77
# rubocop:enable Style/MutableConstant

spec/cirro_io/client/app_user_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,19 @@
4040

4141
expect(app_user.id).to eq('3')
4242
end
43+
44+
it 'returns app user with app-worker and gig invitations' do
45+
stub_request(:get, "#{test_site}/v1/app-users/30?include=app-worker.gig-invitations")
46+
.to_return(body: File.read('./spec/fixtures/app_user_with_app_worker_and_gig_invitations.json'), headers: { 'Content-Type' => 'application/json' })
47+
48+
app_user = described_class.includes('app_worker.gig_invitations').find(30).first
49+
50+
expect(app_user.id).to eq('30')
51+
expect(app_user.app_worker).to be_present
52+
expect(app_user.app_worker.class.to_s).to eq('CirroIO::Client::AppWorker')
53+
54+
expect(app_user.app_worker.gig_invitations.count).to eq(1)
55+
expect(app_user.app_worker.gig_invitations[0].class.to_s).to eq('CirroIO::Client::GigInvitation')
56+
end
4357
end
4458
end
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"data": {
3+
"id": "30",
4+
"type": "app-users",
5+
"links": {
6+
"self": "http://api.app.localhost:3000/api/v1/app-users/30"
7+
},
8+
"attributes": {
9+
"email": "[email protected]",
10+
"first-name": "Inderpal",
11+
"last-name": "Singh",
12+
"time-zone": "Berlin",
13+
"screenname": "abcd1234",
14+
"epam-idx": null,
15+
"country-code": null
16+
},
17+
"relationships": {
18+
"app-worker": {
19+
"data": {
20+
"type": "app-workers",
21+
"id": "7"
22+
}
23+
}
24+
}
25+
},
26+
"included": [
27+
{
28+
"id": "7",
29+
"type": "app-workers",
30+
"links": {
31+
"self": "http://api.app.localhost:3000/api/v1/app-workers/7"
32+
},
33+
"attributes": {
34+
"worker-document": {
35+
"app_worker_id": 7,
36+
"email": "[email protected]"
37+
}
38+
},
39+
"relationships": {
40+
"gig-invitations": {
41+
"data": [
42+
{
43+
"type": "gig-invitations",
44+
"id": "5"
45+
}
46+
]
47+
}
48+
}
49+
},
50+
{
51+
"id": "5",
52+
"type": "gig-invitations",
53+
"attributes": {
54+
"status": "pending",
55+
"gig-id": 4
56+
}
57+
}
58+
]
59+
}

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
require 'webmock/rspec'
88

99
def test_app_id
10-
'cirro-app-id-development' # Change this to a real one to
10+
'cirro-example-app-id-development' # Change this to a real one to
1111
end
1212

1313
def test_site

0 commit comments

Comments
 (0)