global-registry-bindings 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -35
- data/lib/global_registry_bindings/entity/entity_type_methods.rb +35 -33
- data/lib/global_registry_bindings/entity/mdm_methods.rb +9 -19
- data/lib/global_registry_bindings/entity/push_entity_methods.rb +31 -38
- data/lib/global_registry_bindings/entity/push_relationship_methods.rb +61 -47
- data/lib/global_registry_bindings/entity/relationship_type_methods.rb +48 -37
- data/lib/global_registry_bindings/exceptions.rb +1 -0
- data/lib/global_registry_bindings/global_registry_bindings.rb +129 -46
- data/lib/global_registry_bindings/{entity/delete_entity_methods.rb → model/delete_entity.rb} +5 -5
- data/lib/global_registry_bindings/model/entity.rb +64 -0
- data/lib/global_registry_bindings/model/pull_mdm.rb +23 -0
- data/lib/global_registry_bindings/model/push_entity.rb +21 -0
- data/lib/global_registry_bindings/model/push_relationship.rb +79 -0
- data/lib/global_registry_bindings/model/relationship.rb +68 -0
- data/lib/global_registry_bindings/options.rb +26 -59
- data/lib/global_registry_bindings/options/entity_class_options.rb +34 -0
- data/lib/global_registry_bindings/options/entity_instance_options.rb +90 -0
- data/lib/global_registry_bindings/options/entity_options_parser.rb +76 -0
- data/lib/global_registry_bindings/options/relationship_class_options.rb +37 -0
- data/lib/global_registry_bindings/options/relationship_instance_options.rb +131 -0
- data/lib/global_registry_bindings/options/relationship_options_parser.rb +98 -0
- data/lib/global_registry_bindings/railtie.rb +2 -1
- data/lib/global_registry_bindings/version.rb +1 -1
- data/lib/global_registry_bindings/worker.rb +25 -0
- data/lib/global_registry_bindings/workers/{delete_gr_entity_worker.rb → delete_entity_worker.rb} +1 -6
- data/lib/global_registry_bindings/workers/pull_mdm_id_worker.rb +12 -13
- data/lib/global_registry_bindings/workers/push_entity_worker.rb +24 -0
- data/lib/global_registry_bindings/workers/push_relationship_worker.rb +17 -7
- data/spec/acceptance/global_registry_bindings_spec.rb +50 -40
- data/spec/factories/factories.rb +24 -0
- data/spec/fixtures/get_entity_types_area.json +44 -0
- data/spec/fixtures/post_entities_community.json +8 -0
- data/spec/fixtures/post_relationship_types_fancy_org_area.json +16 -0
- data/spec/fixtures/put_entities_community_relationship.json +16 -0
- data/spec/fixtures/put_entities_fancy_org_area_relationship.json +8 -0
- data/spec/fixtures/put_entities_fancy_org_relationship.json +17 -0
- data/spec/fixtures/put_entities_person_country_relationship.json +23 -0
- data/spec/fixtures/put_entities_relationship_400.json +3 -0
- data/spec/fixtures/put_relationship_types_fields_fancy_org_area.json +25 -0
- data/spec/helpers/sidekiq_helpers.rb +14 -0
- data/spec/internal/app/models/address.rb +7 -2
- data/spec/internal/app/models/area.rb +7 -0
- data/spec/internal/app/models/assignment.rb +5 -4
- data/spec/internal/app/models/community.rb +19 -0
- data/spec/internal/app/models/country.rb +8 -0
- data/spec/internal/app/models/namespaced/person.rb +48 -2
- data/spec/internal/app/models/organization.rb +26 -3
- data/spec/internal/db/schema.rb +28 -0
- data/spec/internal/log/test.log +71023 -0
- data/spec/models/address_spec.rb +6 -204
- data/spec/models/assignment_spec.rb +40 -186
- data/spec/models/organization_spec.rb +106 -92
- data/spec/models/person_spec.rb +158 -214
- data/spec/models/user_edited_person_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -6
- data/spec/workers/delete_gr_entity_worker_spec.rb +4 -4
- data/spec/workers/pull_mdm_id_worker_spec.rb +94 -32
- data/spec/workers/push_entity_worker_spec.rb +476 -0
- data/spec/workers/push_relationship_worker_spec.rb +344 -15
- metadata +45 -10
- data/lib/global_registry_bindings/entity/entity_methods.rb +0 -62
- data/lib/global_registry_bindings/options/class_options.rb +0 -62
- data/lib/global_registry_bindings/options/instance_options.rb +0 -63
- data/lib/global_registry_bindings/workers/push_gr_entity_worker.rb +0 -22
- data/spec/workers/push_gr_entity_worker_spec.rb +0 -27
@@ -2,26 +2,355 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
RSpec.describe
|
6
|
-
|
7
|
-
|
5
|
+
RSpec.describe GlobalRegistry::Bindings::Workers::PushRelationshipWorker do
|
6
|
+
around { |example| travel_to Time.utc(2001, 2, 3), &example }
|
7
|
+
describe '#perform(model_class, id, type)' do
|
8
|
+
context Assignment do
|
9
|
+
let(:assignment) { create(:assignment) }
|
10
|
+
context 'with valid id' do
|
11
|
+
it 'should call #push_relationship_to_global_registry' do
|
12
|
+
expect(Assignment).to receive(:find).with(assignment.id).and_return(assignment)
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
worker = GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new
|
15
|
+
expect(worker).to receive(:push_relationship_to_global_registry)
|
16
|
+
worker.perform('Assignment', assignment.id, :assignment)
|
17
|
+
expect(worker.model).to be assignment
|
18
|
+
end
|
19
|
+
end
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
context 'with invalid id' do
|
22
|
+
it 'should fail silently' do
|
23
|
+
expect(Assignment).to receive(:find).with(assignment.id).and_raise(ActiveRecord::RecordNotFound)
|
24
|
+
expect(GlobalRegistry::Bindings::Workers::PushRelationshipWorker)
|
25
|
+
.not_to receive(:push_relationship_to_global_registry)
|
26
|
+
|
27
|
+
worker = GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new
|
28
|
+
worker.perform(Assignment, assignment.id, :assignment)
|
29
|
+
expect(worker.model).to be nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#push_relationship_to_global_registry' do
|
36
|
+
describe Assignment do
|
37
|
+
let(:worker) { GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new assignment, :assignment }
|
38
|
+
context 'as create' do
|
39
|
+
let(:person) { create(:person, global_registry_id: '22527d88-3cba-11e7-b876-129bd0521531') }
|
40
|
+
let(:organization) { create(:organization, gr_id: 'aebb4170-3f34-11e7-bba6-129bd0521531') }
|
41
|
+
let(:assignment) { create(:assignment, person: person, organization: organization) }
|
42
|
+
let!(:requests) do
|
43
|
+
[stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
44
|
+
.with(query: { 'filters[name]' => 'person', 'filters[parent_id]' => nil })
|
45
|
+
.to_return(body: file_fixture('get_entity_types_person.json'), status: 200),
|
46
|
+
stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
47
|
+
.with(query: { 'filters[name]' => 'fancy_org', 'filters[parent_id]' => nil })
|
48
|
+
.to_return(body: file_fixture('get_entity_types_fancy_org.json'), status: 200),
|
49
|
+
stub_request(:put, "https://backend.global-registry.org/entities/#{person.global_registry_id}")
|
50
|
+
.with(body: { entity: { person: { 'fancy_org:relationship': {
|
51
|
+
role: 'leader', hired_at: '2000-12-03 00:00:00',
|
52
|
+
client_integration_id: assignment.id,
|
53
|
+
client_updated_at: '2001-02-03 00:00:00', fancy_org: organization.gr_id
|
54
|
+
} }, client_integration_id: person.id } }, query: { full_response: 'true',
|
55
|
+
fields: 'fancy_org:relationship' })
|
56
|
+
.to_return(body: file_fixture('put_entities_person_relationship.json'), status: 200)]
|
57
|
+
end
|
58
|
+
|
59
|
+
context '\'assignment\' relationship_type does not exist' do
|
60
|
+
let!(:sub_requests) do
|
61
|
+
[stub_request(:get, 'https://backend.global-registry.org/relationship_types')
|
62
|
+
.with(query: { 'filters[between]' =>
|
63
|
+
'ee13a693-3ce7-4c19-b59a-30c8f137acd8,025a1128-3f33-11e7-b876-129bd0521531' })
|
64
|
+
.to_return(body: file_fixture('get_relationship_types.json'), status: 200),
|
65
|
+
stub_request(:post, 'https://backend.global-registry.org/relationship_types')
|
66
|
+
.with(body: { relationship_type: { entity_type1_id: 'ee13a693-3ce7-4c19-b59a-30c8f137acd8',
|
67
|
+
entity_type2_id: '025a1128-3f33-11e7-b876-129bd0521531',
|
68
|
+
relationship1: 'person', relationship2: 'fancy_org' } })
|
69
|
+
.to_return(body: file_fixture('post_relationship_types_person_fancy_org.json'), status: 200),
|
70
|
+
stub_request(:put,
|
71
|
+
'https://backend.global-registry.org/relationship_types/5d721db8-4248-11e7-90b4-129bd0521531')
|
72
|
+
.with(body: { relationship_type: { fields: [{ name: 'role', field_type: 'string' },
|
73
|
+
{ name: 'hired_at', field_type: 'datetime' }] } })
|
74
|
+
.to_return(body: file_fixture('put_relationship_types_fields.json'), status: 200)]
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should create \'assignment\' relationship_type and push relationship' do
|
78
|
+
worker.push_relationship_to_global_registry
|
79
|
+
(requests + sub_requests).each { |r| expect(r).to have_been_requested.once }
|
80
|
+
expect(assignment.global_registry_id).to eq '51a014a4-4252-11e7-944f-129bd0521531'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context '\'assignment\' relationship_type partially exists' do
|
85
|
+
let!(:sub_requests) do
|
86
|
+
[stub_request(:get, 'https://backend.global-registry.org/relationship_types')
|
87
|
+
.with(query: { 'filters[between]' =>
|
88
|
+
'ee13a693-3ce7-4c19-b59a-30c8f137acd8,025a1128-3f33-11e7-b876-129bd0521531' })
|
89
|
+
.to_return(body: file_fixture('get_relationship_types_person_fancy_org_partial.json'), status: 200),
|
90
|
+
stub_request(:put,
|
91
|
+
'https://backend.global-registry.org/relationship_types/5d721db8-4248-11e7-90b4-129bd0521531')
|
92
|
+
.with(body: { relationship_type: { fields: [{ name: 'role', field_type: 'string' }] } })
|
93
|
+
.to_return(body: file_fixture('put_relationship_types_fields.json'), status: 200)]
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should add fields to relationship type and push relationship' do
|
97
|
+
worker.push_relationship_to_global_registry
|
98
|
+
(requests + sub_requests).each { |r| expect(r).to have_been_requested.once }
|
99
|
+
expect(assignment.global_registry_id).to eq '51a014a4-4252-11e7-944f-129bd0521531'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context '\'assignment\' relationship_type exists' do
|
104
|
+
let!(:sub_requests) do
|
105
|
+
[stub_request(:get, 'https://backend.global-registry.org/relationship_types')
|
106
|
+
.with(query: { 'filters[between]' =>
|
107
|
+
'ee13a693-3ce7-4c19-b59a-30c8f137acd8,025a1128-3f33-11e7-b876-129bd0521531' })
|
108
|
+
.to_return(body: file_fixture('get_relationship_types_person_fancy_org.json'), status: 200)]
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should add fields to relationship type and push relationship' do
|
112
|
+
worker.push_relationship_to_global_registry
|
113
|
+
(requests + sub_requests).each { |r| expect(r).to have_been_requested.once }
|
114
|
+
expect(assignment.global_registry_id).to eq '51a014a4-4252-11e7-944f-129bd0521531'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'as an update' do
|
120
|
+
let(:person) { create(:person, global_registry_id: '22527d88-3cba-11e7-b876-129bd0521531') }
|
121
|
+
let(:organization) { create(:organization, gr_id: 'aebb4170-3f34-11e7-bba6-129bd0521531') }
|
122
|
+
let(:assignment) do
|
123
|
+
create(:assignment, person: person, organization: organization,
|
124
|
+
global_registry_id: '51a014a4-4252-11e7-944f-129bd0521531')
|
125
|
+
end
|
126
|
+
|
127
|
+
context '\'assignment\' relationship_type is cached' do
|
128
|
+
before :each do
|
129
|
+
person_entity_types = JSON.parse(file_fixture('get_entity_types_person.json').read)
|
130
|
+
organization_entity_types = JSON.parse(file_fixture('get_entity_types_fancy_org.json').read)
|
131
|
+
assignment_relationship_type = JSON.parse(file_fixture('get_relationship_types_person_fancy_org.json').read)
|
132
|
+
Rails.cache.write('GlobalRegistry::Bindings::EntityType::person', person_entity_types['entity_types'].first)
|
133
|
+
Rails.cache.write('GlobalRegistry::Bindings::EntityType::fancy_org',
|
134
|
+
organization_entity_types['entity_types'].first)
|
135
|
+
Rails.cache.write('GlobalRegistry::Bindings::RelationshipType::person::fancy_org::person',
|
136
|
+
assignment_relationship_type['relationship_types'].first)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should push relationship' do
|
140
|
+
request = stub_request(:put, "https://backend.global-registry.org/entities/#{person.global_registry_id}")
|
141
|
+
.with(body: { entity: { person: { 'fancy_org:relationship': {
|
142
|
+
role: 'leader', hired_at: '2000-12-03 00:00:00',
|
143
|
+
client_integration_id: assignment.id,
|
144
|
+
client_updated_at: '2001-02-03 00:00:00', fancy_org: organization.gr_id
|
145
|
+
} }, client_integration_id: person.id } }, query: { full_response: 'true',
|
146
|
+
fields: 'fancy_org:relationship' })
|
147
|
+
.to_return(body: file_fixture('put_entities_person_relationship.json'), status: 200,
|
148
|
+
headers: { 'Content-Type' => 'application/json' })
|
149
|
+
|
150
|
+
worker.push_relationship_to_global_registry
|
151
|
+
expect(request).to have_been_requested.once
|
152
|
+
expect(assignment.global_registry_id).to eq '51a014a4-4252-11e7-944f-129bd0521531'
|
153
|
+
end
|
154
|
+
|
155
|
+
context '\'fancy_org\' foreign key changed' do
|
156
|
+
let!(:requests) do
|
157
|
+
[stub_request(:put, "https://backend.global-registry.org/entities/#{person.global_registry_id}")
|
158
|
+
.with(body: { entity: { person: { 'fancy_org:relationship': {
|
159
|
+
role: 'leader', hired_at: '2000-12-03 00:00:00',
|
160
|
+
client_integration_id: assignment.id,
|
161
|
+
client_updated_at: '2001-02-03 00:00:00', fancy_org: organization.gr_id
|
162
|
+
} }, client_integration_id: person.id } }, query: { full_response: 'true',
|
163
|
+
fields: 'fancy_org:relationship' })
|
164
|
+
.to_return(body: file_fixture('put_entities_relationship_400.json'), status: 400),
|
165
|
+
stub_request(:delete,
|
166
|
+
'https://backend.global-registry.org/entities/51a014a4-4252-11e7-944f-129bd0521531')
|
167
|
+
.to_return(status: 200)]
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should delete relationship and retry' do
|
171
|
+
expect do
|
172
|
+
worker.push_relationship_to_global_registry
|
173
|
+
end.to raise_error(GlobalRegistry::Bindings::RelatedEntityExistsWithCID)
|
174
|
+
requests.each { |r| expect(r).to have_been_requested.once }
|
175
|
+
expect(assignment.global_registry_id).to be_nil
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'related entities missing global_registry_id' do
|
182
|
+
context '\'person\' missing global_registry_id' do
|
183
|
+
let(:person) { build(:person) }
|
184
|
+
let(:organization) { build(:organization, gr_id: 'aebb4170-3f34-11e7-bba6-129bd0521531') }
|
185
|
+
let!(:assignment) { create(:assignment, person: person, organization: organization) }
|
186
|
+
|
187
|
+
it 'should raise an exception' do
|
188
|
+
clear_sidekiq_jobs_and_locks
|
189
|
+
|
190
|
+
expect do
|
191
|
+
worker.push_relationship_to_global_registry
|
192
|
+
end.to raise_error(GlobalRegistry::Bindings::RelatedEntityMissingGlobalRegistryId).and(
|
193
|
+
change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1)
|
194
|
+
)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context '\'organization\' missing global_registry_id' do
|
199
|
+
let(:person) { build(:person, global_registry_id: '22527d88-3cba-11e7-b876-129bd0521531') }
|
200
|
+
let(:organization) { build(:organization) }
|
201
|
+
let!(:assignment) { create(:assignment, person: person, organization: organization) }
|
202
|
+
|
203
|
+
it 'should raise an exception' do
|
204
|
+
clear_sidekiq_jobs_and_locks
|
205
|
+
|
206
|
+
expect do
|
207
|
+
worker.push_relationship_to_global_registry
|
208
|
+
end.to raise_error(GlobalRegistry::Bindings::RelatedEntityMissingGlobalRegistryId).and(
|
209
|
+
change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1)
|
210
|
+
)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context '\'person\' and \'organization\' missing global_registry_id' do
|
215
|
+
let(:person) { build(:person) }
|
216
|
+
let(:organization) { build(:organization) }
|
217
|
+
let!(:assignment) { create(:assignment, person: person, organization: organization) }
|
218
|
+
|
219
|
+
it 'should raise an exception' do
|
220
|
+
clear_sidekiq_jobs_and_locks
|
221
|
+
|
222
|
+
expect do
|
223
|
+
worker.push_relationship_to_global_registry
|
224
|
+
end.to raise_error(GlobalRegistry::Bindings::RelatedEntityMissingGlobalRegistryId).and(
|
225
|
+
change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(2)
|
226
|
+
)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe Organization do
|
233
|
+
let(:worker) { GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new organization, :area }
|
234
|
+
context 'as create' do
|
235
|
+
let(:area) { create(:area, global_registry_id: '0fdb70c5-f51e-4628-a1fe-caa37fae53cd') }
|
236
|
+
let(:organization) { create(:organization, gr_id: 'aebb4170-3f34-11e7-bba6-129bd0521531', area: area) }
|
237
|
+
let!(:requests) do
|
238
|
+
[stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
239
|
+
.with(query: { 'filters[name]' => 'fancy_org', 'filters[parent_id]' => nil })
|
240
|
+
.to_return(body: file_fixture('get_entity_types_fancy_org.json'), status: 200),
|
241
|
+
stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
242
|
+
.with(query: { 'filters[name]' => 'area', 'filters[parent_id]' => nil })
|
243
|
+
.to_return(body: file_fixture('get_entity_types_area.json'), status: 200),
|
244
|
+
stub_request(:put, "https://backend.global-registry.org/entities/#{organization.gr_id}")
|
245
|
+
.with(body: { entity: { fancy_org: { 'area:relationship': {
|
246
|
+
priority: 'High',
|
247
|
+
client_integration_id: organization.id,
|
248
|
+
client_updated_at: '2001-02-03 00:00:00', area: area.global_registry_id
|
249
|
+
} }, client_integration_id: organization.id } },
|
250
|
+
query: { full_response: 'true', fields: 'area:relationship' })
|
251
|
+
.to_return(body: file_fixture('put_entities_fancy_org_relationship.json'), status: 200)]
|
252
|
+
end
|
253
|
+
|
254
|
+
context '\'area\' relationship_type does not exist' do
|
255
|
+
let!(:sub_requests) do
|
256
|
+
[stub_request(:get, 'https://backend.global-registry.org/relationship_types')
|
257
|
+
.with(query: { 'filters[between]' =>
|
258
|
+
'025a1128-3f33-11e7-b876-129bd0521531,548852c6-d55e-11e3-897f-12725f8f377c' })
|
259
|
+
.to_return(body: file_fixture('get_relationship_types.json'), status: 200),
|
260
|
+
stub_request(:post, 'https://backend.global-registry.org/relationship_types')
|
261
|
+
.with(body: { relationship_type: { entity_type1_id: '025a1128-3f33-11e7-b876-129bd0521531',
|
262
|
+
entity_type2_id: '548852c6-d55e-11e3-897f-12725f8f377c',
|
263
|
+
relationship1: 'fancy_org', relationship2: 'area' } })
|
264
|
+
.to_return(body: file_fixture('post_relationship_types_fancy_org_area.json'), status: 200),
|
265
|
+
stub_request(:put,
|
266
|
+
'https://backend.global-registry.org/relationship_types/f03b947e-6644-11e7-93dd-129bd0521531')
|
267
|
+
.with(body: { relationship_type: { fields: [{ name: 'priority', field_type: 'string' }] } })
|
268
|
+
.to_return(body: file_fixture('put_relationship_types_fields_fancy_org_area.json'), status: 200)]
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should create \'area\' relationship_type and push relationship' do
|
272
|
+
worker.push_relationship_to_global_registry
|
273
|
+
(requests + sub_requests).each { |r| expect(r).to have_been_requested.once }
|
274
|
+
expect(organization.global_registry_area_id).to eq 'c99d7d7e-8b14-4fe6-9c11-e5359ee03637'
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
describe Namespaced::Person do
|
281
|
+
describe 'country_of_service' do
|
282
|
+
let(:worker) { GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new person, :country_of_service }
|
283
|
+
context 'as create' do
|
284
|
+
let(:country) { create(:country, global_registry_id: '0f9089a3-2b93-4de8-9b81-92be0261f325') }
|
285
|
+
let(:person) do
|
286
|
+
create(:person, global_registry_id: '2f0c62f1-5738-4860-88bd-5706fb801d7b', country_of_service: country)
|
287
|
+
end
|
288
|
+
let!(:request) do
|
289
|
+
stub_request(:put, "https://backend.global-registry.org/entities/#{person.global_registry_id}")
|
290
|
+
.with(body: { entity: { person: { 'country:relationship': {
|
291
|
+
client_integration_id: "cos_#{person.id}",
|
292
|
+
client_updated_at: '2001-02-03 00:00:00', country_of_service: true,
|
293
|
+
country: country.global_registry_id
|
294
|
+
} }, client_integration_id: person.id } },
|
295
|
+
query: { full_response: 'true', fields: 'country:relationship' })
|
296
|
+
.to_return(body: file_fixture('put_entities_person_country_relationship.json'), status: 200)
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should push relationship' do
|
300
|
+
worker.push_relationship_to_global_registry
|
301
|
+
expect(request).to have_been_requested.once
|
302
|
+
expect(person.country_of_service_gr_id).to eq '420d2fd1-7a73-41ed-9d8f-5dc79b00a688'
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe 'country_of_residence' do
|
308
|
+
let(:worker) { GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new person, :country_of_residence }
|
309
|
+
context 'as create' do
|
310
|
+
let(:country) { create(:country, global_registry_id: '7cdaf399-d449-4008-8c6b-3c64a2b2730c') }
|
311
|
+
let(:person) do
|
312
|
+
create(:person, global_registry_id: '2f0c62f1-5738-4860-88bd-5706fb801d7b', country_of_residence: country)
|
313
|
+
end
|
314
|
+
let!(:request) do
|
315
|
+
stub_request(:put, "https://backend.global-registry.org/entities/#{person.global_registry_id}")
|
316
|
+
.with(body: { entity: { person: { 'country:relationship': {
|
317
|
+
client_integration_id: "cor_#{person.id}",
|
318
|
+
client_updated_at: '2001-02-03 00:00:00', country_of_residence: true,
|
319
|
+
country: country.global_registry_id
|
320
|
+
} }, client_integration_id: person.id } },
|
321
|
+
query: { full_response: 'true', fields: 'country:relationship' })
|
322
|
+
.to_return(body: file_fixture('put_entities_person_country_relationship.json'), status: 200)
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'should push relationship' do
|
326
|
+
worker.push_relationship_to_global_registry
|
327
|
+
expect(request).to have_been_requested.once
|
328
|
+
expect(person.country_of_residence_gr_id).to eq 'a4c030ce-13f2-44f5-8131-4003eb21c0ae'
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
16
332
|
end
|
17
333
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
334
|
+
describe Community do
|
335
|
+
let(:worker) { GlobalRegistry::Bindings::Workers::PushRelationshipWorker.new community, :infobase_ministry }
|
336
|
+
let(:community) do
|
337
|
+
create(:community, global_registry_id: '6133f6fe-c63a-425a-bb46-68917c689723', infobase_id: 2345)
|
338
|
+
end
|
339
|
+
let!(:request) do
|
340
|
+
stub_request(:put, "https://backend.global-registry.org/entities/#{community.global_registry_id}")
|
341
|
+
.with(body: { entity: { community: { 'ministry:relationship': {
|
342
|
+
client_integration_id: community.id, client_updated_at: '2001-02-03 00:00:00',
|
343
|
+
ministry: '41f767fd-86f4-42e2-8d24-cbc3f697b794'
|
344
|
+
} }, client_integration_id: community.id } },
|
345
|
+
query: { full_response: 'true', fields: 'ministry:relationship' })
|
346
|
+
.to_return(body: file_fixture('put_entities_community_relationship.json'), status: 200)
|
347
|
+
end
|
22
348
|
|
23
|
-
|
24
|
-
|
349
|
+
it 'should push relationship' do
|
350
|
+
worker.push_relationship_to_global_registry
|
351
|
+
expect(request).to have_been_requested.once
|
352
|
+
expect(community.infobase_gr_id).to eq 'ee40f9ed-d625-405b-8ce6-aec821611ec6'
|
353
|
+
end
|
25
354
|
end
|
26
355
|
end
|
27
356
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global-registry-bindings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Zoetewey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -297,8 +297,6 @@ files:
|
|
297
297
|
- MIT-LICENSE
|
298
298
|
- README.md
|
299
299
|
- lib/global_registry_bindings.rb
|
300
|
-
- lib/global_registry_bindings/entity/delete_entity_methods.rb
|
301
|
-
- lib/global_registry_bindings/entity/entity_methods.rb
|
302
300
|
- lib/global_registry_bindings/entity/entity_type_methods.rb
|
303
301
|
- lib/global_registry_bindings/entity/mdm_methods.rb
|
304
302
|
- lib/global_registry_bindings/entity/push_entity_methods.rb
|
@@ -306,14 +304,25 @@ files:
|
|
306
304
|
- lib/global_registry_bindings/entity/relationship_type_methods.rb
|
307
305
|
- lib/global_registry_bindings/exceptions.rb
|
308
306
|
- lib/global_registry_bindings/global_registry_bindings.rb
|
307
|
+
- lib/global_registry_bindings/model/delete_entity.rb
|
308
|
+
- lib/global_registry_bindings/model/entity.rb
|
309
|
+
- lib/global_registry_bindings/model/pull_mdm.rb
|
310
|
+
- lib/global_registry_bindings/model/push_entity.rb
|
311
|
+
- lib/global_registry_bindings/model/push_relationship.rb
|
312
|
+
- lib/global_registry_bindings/model/relationship.rb
|
309
313
|
- lib/global_registry_bindings/options.rb
|
310
|
-
- lib/global_registry_bindings/options/
|
311
|
-
- lib/global_registry_bindings/options/
|
314
|
+
- lib/global_registry_bindings/options/entity_class_options.rb
|
315
|
+
- lib/global_registry_bindings/options/entity_instance_options.rb
|
316
|
+
- lib/global_registry_bindings/options/entity_options_parser.rb
|
317
|
+
- lib/global_registry_bindings/options/relationship_class_options.rb
|
318
|
+
- lib/global_registry_bindings/options/relationship_instance_options.rb
|
319
|
+
- lib/global_registry_bindings/options/relationship_options_parser.rb
|
312
320
|
- lib/global_registry_bindings/railtie.rb
|
313
321
|
- lib/global_registry_bindings/version.rb
|
314
|
-
- lib/global_registry_bindings/
|
322
|
+
- lib/global_registry_bindings/worker.rb
|
323
|
+
- lib/global_registry_bindings/workers/delete_entity_worker.rb
|
315
324
|
- lib/global_registry_bindings/workers/pull_mdm_id_worker.rb
|
316
|
-
- lib/global_registry_bindings/workers/
|
325
|
+
- lib/global_registry_bindings/workers/push_entity_worker.rb
|
317
326
|
- lib/global_registry_bindings/workers/push_relationship_worker.rb
|
318
327
|
- spec/acceptance/global_registry_bindings_spec.rb
|
319
328
|
- spec/factories/factories.rb
|
@@ -323,6 +332,7 @@ files:
|
|
323
332
|
- spec/fixtures/get_entity_types.json
|
324
333
|
- spec/fixtures/get_entity_types_address.json
|
325
334
|
- spec/fixtures/get_entity_types_address_partial.json
|
335
|
+
- spec/fixtures/get_entity_types_area.json
|
326
336
|
- spec/fixtures/get_entity_types_fancy_org.json
|
327
337
|
- spec/fixtures/get_entity_types_fancy_org_partial.json
|
328
338
|
- spec/fixtures/get_entity_types_person.json
|
@@ -330,20 +340,32 @@ files:
|
|
330
340
|
- spec/fixtures/get_relationship_types.json
|
331
341
|
- spec/fixtures/get_relationship_types_person_fancy_org.json
|
332
342
|
- spec/fixtures/get_relationship_types_person_fancy_org_partial.json
|
343
|
+
- spec/fixtures/post_entities_community.json
|
333
344
|
- spec/fixtures/post_entities_fancy_org.json
|
334
345
|
- spec/fixtures/post_entities_fancy_org_parent.json
|
335
346
|
- spec/fixtures/post_entities_person.json
|
336
347
|
- spec/fixtures/post_entity_types_address.json
|
337
348
|
- spec/fixtures/post_entity_types_fancy_org.json
|
338
349
|
- spec/fixtures/post_entity_types_person.json
|
350
|
+
- spec/fixtures/post_relationship_types_fancy_org_area.json
|
339
351
|
- spec/fixtures/post_relationship_types_person_fancy_org.json
|
340
352
|
- spec/fixtures/put_entities_address.json
|
353
|
+
- spec/fixtures/put_entities_community_relationship.json
|
354
|
+
- spec/fixtures/put_entities_fancy_org_area_relationship.json
|
355
|
+
- spec/fixtures/put_entities_fancy_org_relationship.json
|
356
|
+
- spec/fixtures/put_entities_person_country_relationship.json
|
341
357
|
- spec/fixtures/put_entities_person_relationship.json
|
342
358
|
- spec/fixtures/put_entities_relationship.json
|
359
|
+
- spec/fixtures/put_entities_relationship_400.json
|
343
360
|
- spec/fixtures/put_relationship_types_fields.json
|
361
|
+
- spec/fixtures/put_relationship_types_fields_fancy_org_area.json
|
362
|
+
- spec/helpers/sidekiq_helpers.rb
|
344
363
|
- spec/internal/app/models/address.rb
|
345
364
|
- spec/internal/app/models/application_record.rb
|
365
|
+
- spec/internal/app/models/area.rb
|
346
366
|
- spec/internal/app/models/assignment.rb
|
367
|
+
- spec/internal/app/models/community.rb
|
368
|
+
- spec/internal/app/models/country.rb
|
347
369
|
- spec/internal/app/models/default.rb
|
348
370
|
- spec/internal/app/models/namespaced/person.rb
|
349
371
|
- spec/internal/app/models/namespaced/person/user_edited.rb
|
@@ -361,7 +383,7 @@ files:
|
|
361
383
|
- spec/spec_helper.rb
|
362
384
|
- spec/workers/delete_gr_entity_worker_spec.rb
|
363
385
|
- spec/workers/pull_mdm_id_worker_spec.rb
|
364
|
-
- spec/workers/
|
386
|
+
- spec/workers/push_entity_worker_spec.rb
|
365
387
|
- spec/workers/push_relationship_worker_spec.rb
|
366
388
|
homepage: https://github.com/CruGlobal/global-registry-bindings
|
367
389
|
licenses:
|
@@ -396,6 +418,7 @@ test_files:
|
|
396
418
|
- spec/fixtures/get_entity_types.json
|
397
419
|
- spec/fixtures/get_entity_types_address.json
|
398
420
|
- spec/fixtures/get_entity_types_address_partial.json
|
421
|
+
- spec/fixtures/get_entity_types_area.json
|
399
422
|
- spec/fixtures/get_entity_types_fancy_org.json
|
400
423
|
- spec/fixtures/get_entity_types_fancy_org_partial.json
|
401
424
|
- spec/fixtures/get_entity_types_person.json
|
@@ -403,20 +426,32 @@ test_files:
|
|
403
426
|
- spec/fixtures/get_relationship_types.json
|
404
427
|
- spec/fixtures/get_relationship_types_person_fancy_org.json
|
405
428
|
- spec/fixtures/get_relationship_types_person_fancy_org_partial.json
|
429
|
+
- spec/fixtures/post_entities_community.json
|
406
430
|
- spec/fixtures/post_entities_fancy_org.json
|
407
431
|
- spec/fixtures/post_entities_fancy_org_parent.json
|
408
432
|
- spec/fixtures/post_entities_person.json
|
409
433
|
- spec/fixtures/post_entity_types_address.json
|
410
434
|
- spec/fixtures/post_entity_types_fancy_org.json
|
411
435
|
- spec/fixtures/post_entity_types_person.json
|
436
|
+
- spec/fixtures/post_relationship_types_fancy_org_area.json
|
412
437
|
- spec/fixtures/post_relationship_types_person_fancy_org.json
|
413
438
|
- spec/fixtures/put_entities_address.json
|
439
|
+
- spec/fixtures/put_entities_community_relationship.json
|
440
|
+
- spec/fixtures/put_entities_fancy_org_area_relationship.json
|
441
|
+
- spec/fixtures/put_entities_fancy_org_relationship.json
|
442
|
+
- spec/fixtures/put_entities_person_country_relationship.json
|
414
443
|
- spec/fixtures/put_entities_person_relationship.json
|
415
444
|
- spec/fixtures/put_entities_relationship.json
|
445
|
+
- spec/fixtures/put_entities_relationship_400.json
|
416
446
|
- spec/fixtures/put_relationship_types_fields.json
|
447
|
+
- spec/fixtures/put_relationship_types_fields_fancy_org_area.json
|
448
|
+
- spec/helpers/sidekiq_helpers.rb
|
417
449
|
- spec/internal/app/models/address.rb
|
418
450
|
- spec/internal/app/models/application_record.rb
|
451
|
+
- spec/internal/app/models/area.rb
|
419
452
|
- spec/internal/app/models/assignment.rb
|
453
|
+
- spec/internal/app/models/community.rb
|
454
|
+
- spec/internal/app/models/country.rb
|
420
455
|
- spec/internal/app/models/default.rb
|
421
456
|
- spec/internal/app/models/namespaced/person/user_edited.rb
|
422
457
|
- spec/internal/app/models/namespaced/person.rb
|
@@ -434,5 +469,5 @@ test_files:
|
|
434
469
|
- spec/spec_helper.rb
|
435
470
|
- spec/workers/delete_gr_entity_worker_spec.rb
|
436
471
|
- spec/workers/pull_mdm_id_worker_spec.rb
|
437
|
-
- spec/workers/
|
472
|
+
- spec/workers/push_entity_worker_spec.rb
|
438
473
|
- spec/workers/push_relationship_worker_spec.rb
|