global-registry-bindings 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/global_registry_bindings/entity/relationship_type_methods.rb +28 -4
- data/lib/global_registry_bindings/exceptions.rb +1 -0
- data/lib/global_registry_bindings/options/relationship_instance_options.rb +0 -1
- data/lib/global_registry_bindings/version.rb +1 -1
- data/spec/fixtures/get_entity_types_community.json +18 -0
- data/spec/fixtures/get_entity_types_ministry.json +18 -0
- data/spec/fixtures/post_relationship_types_community_ministry.json +16 -0
- data/spec/internal/app/models/community.rb +1 -2
- data/spec/internal/log/test.log +4994 -0
- data/spec/workers/push_relationship_worker_spec.rb +48 -12
- metadata +8 -2
@@ -336,20 +336,56 @@ RSpec.describe GlobalRegistry::Bindings::Workers::PushRelationshipWorker do
|
|
336
336
|
let(:community) do
|
337
337
|
create(:community, global_registry_id: '6133f6fe-c63a-425a-bb46-68917c689723', infobase_id: 2345)
|
338
338
|
end
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
339
|
+
|
340
|
+
context '\'ministry\' entity_type does not exist' do
|
341
|
+
let!(:requests) do
|
342
|
+
[stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
343
|
+
.with(query: { 'filters[name]' => 'ministry' })
|
344
|
+
.to_return(body: file_fixture('get_entity_types.json'), status: 200),
|
345
|
+
stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
346
|
+
.with(query: { 'filters[name]' => 'community' })
|
347
|
+
.to_return(body: file_fixture('get_entity_types_community.json'), status: 200)]
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should raise an exception' do
|
351
|
+
expect do
|
352
|
+
worker.push_relationship_to_global_registry
|
353
|
+
end.to raise_error(GlobalRegistry::Bindings::RelatedEntityTypeMissing)
|
354
|
+
requests.each { |r| expect(r).to have_been_requested.once }
|
355
|
+
end
|
347
356
|
end
|
348
357
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
358
|
+
context '\'ministry\' entity_type does not exist' do
|
359
|
+
let!(:requests) do
|
360
|
+
[stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
361
|
+
.with(query: { 'filters[name]' => 'ministry' })
|
362
|
+
.to_return(body: file_fixture('get_entity_types_ministry.json'), status: 200),
|
363
|
+
stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
364
|
+
.with(query: { 'filters[name]' => 'community' })
|
365
|
+
.to_return(body: file_fixture('get_entity_types_community.json'), status: 200),
|
366
|
+
stub_request(:get, 'https://backend.global-registry.org/relationship_types')
|
367
|
+
.with(query: { 'filters[between]' =>
|
368
|
+
'3d8a68df-72f3-45f0-848b-4a6322448a6c,f0f0876b-0ebe-4680-9e48-1c3b72523d07' })
|
369
|
+
.to_return(body: file_fixture('get_relationship_types.json'), status: 200),
|
370
|
+
stub_request(:post, 'https://backend.global-registry.org/relationship_types')
|
371
|
+
.with(body: { relationship_type: { entity_type1_id: '3d8a68df-72f3-45f0-848b-4a6322448a6c',
|
372
|
+
entity_type2_id: 'f0f0876b-0ebe-4680-9e48-1c3b72523d07',
|
373
|
+
relationship1: 'community', relationship2: 'ministry' } })
|
374
|
+
.to_return(body: file_fixture('post_relationship_types_community_ministry.json'), status: 200),
|
375
|
+
stub_request(:put, "https://backend.global-registry.org/entities/#{community.global_registry_id}")
|
376
|
+
.with(body: { entity: { community: { 'ministry:relationship': {
|
377
|
+
client_integration_id: community.id, client_updated_at: '2001-02-03 00:00:00',
|
378
|
+
ministry: '41f767fd-86f4-42e2-8d24-cbc3f697b794'
|
379
|
+
} }, client_integration_id: community.id } },
|
380
|
+
query: { full_response: 'true', fields: 'ministry:relationship' })
|
381
|
+
.to_return(body: file_fixture('put_entities_community_relationship.json'), status: 200)]
|
382
|
+
end
|
383
|
+
|
384
|
+
it 'should raise an exception' do
|
385
|
+
worker.push_relationship_to_global_registry
|
386
|
+
requests.each { |r| expect(r).to have_been_requested.once }
|
387
|
+
expect(community.infobase_gr_id).to eq('ee40f9ed-d625-405b-8ce6-aec821611ec6')
|
388
|
+
end
|
353
389
|
end
|
354
390
|
end
|
355
391
|
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.1.
|
4
|
+
version: 0.1.1
|
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-07-
|
11
|
+
date: 2017-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -333,8 +333,10 @@ files:
|
|
333
333
|
- spec/fixtures/get_entity_types_address.json
|
334
334
|
- spec/fixtures/get_entity_types_address_partial.json
|
335
335
|
- spec/fixtures/get_entity_types_area.json
|
336
|
+
- spec/fixtures/get_entity_types_community.json
|
336
337
|
- spec/fixtures/get_entity_types_fancy_org.json
|
337
338
|
- spec/fixtures/get_entity_types_fancy_org_partial.json
|
339
|
+
- spec/fixtures/get_entity_types_ministry.json
|
338
340
|
- spec/fixtures/get_entity_types_person.json
|
339
341
|
- spec/fixtures/get_entity_types_person_partial.json
|
340
342
|
- spec/fixtures/get_relationship_types.json
|
@@ -347,6 +349,7 @@ files:
|
|
347
349
|
- spec/fixtures/post_entity_types_address.json
|
348
350
|
- spec/fixtures/post_entity_types_fancy_org.json
|
349
351
|
- spec/fixtures/post_entity_types_person.json
|
352
|
+
- spec/fixtures/post_relationship_types_community_ministry.json
|
350
353
|
- spec/fixtures/post_relationship_types_fancy_org_area.json
|
351
354
|
- spec/fixtures/post_relationship_types_person_fancy_org.json
|
352
355
|
- spec/fixtures/put_entities_address.json
|
@@ -419,8 +422,10 @@ test_files:
|
|
419
422
|
- spec/fixtures/get_entity_types_address.json
|
420
423
|
- spec/fixtures/get_entity_types_address_partial.json
|
421
424
|
- spec/fixtures/get_entity_types_area.json
|
425
|
+
- spec/fixtures/get_entity_types_community.json
|
422
426
|
- spec/fixtures/get_entity_types_fancy_org.json
|
423
427
|
- spec/fixtures/get_entity_types_fancy_org_partial.json
|
428
|
+
- spec/fixtures/get_entity_types_ministry.json
|
424
429
|
- spec/fixtures/get_entity_types_person.json
|
425
430
|
- spec/fixtures/get_entity_types_person_partial.json
|
426
431
|
- spec/fixtures/get_relationship_types.json
|
@@ -433,6 +438,7 @@ test_files:
|
|
433
438
|
- spec/fixtures/post_entity_types_address.json
|
434
439
|
- spec/fixtures/post_entity_types_fancy_org.json
|
435
440
|
- spec/fixtures/post_entity_types_person.json
|
441
|
+
- spec/fixtures/post_relationship_types_community_ministry.json
|
436
442
|
- spec/fixtures/post_relationship_types_fancy_org_area.json
|
437
443
|
- spec/fixtures/post_relationship_types_person_fancy_org.json
|
438
444
|
- spec/fixtures/put_entities_address.json
|