global-registry-bindings 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fde0711e44617c813c4e88abe88119ddc008c76
4
- data.tar.gz: 4b1f10e75f4b95b7ccfbc2462403bd6cffcf3f6a
3
+ metadata.gz: 4dd8d8a7069e77c3eff998918b8481ebb8c961ef
4
+ data.tar.gz: 9bb711799fc0cc935d1fcb564901f4acad662de4
5
5
  SHA512:
6
- metadata.gz: 170479033b4c6c4d80952dcc9751ccd16e22dd3268d27fb2829380ee03757c51daa4191b9144c4ef48dae7175f6dd977a323fcd4b553ec6529d88deb578d71dd
7
- data.tar.gz: 489177982a94ec7303ce80e311d27bd23392920e2a6e3281ca62ef4937fe7b7c5f8568cfdf19960eed7c4f2dd1bd5943021841c6a9c5d5a65eba6559f6a1f701
6
+ metadata.gz: abd20332493b5b8551079714b63d3eb2e14302586730ed3de4d8324c2c849ac7099533f60615b0bcdcbd830ec8b5c11f3073865c793dde86c4ec17909b4b3878
7
+ data.tar.gz: 7c1a0eeec3b0ff7a3b5c9f01d3bfe2ed77b227231ec51a66536201328209293b685d7db4986d987684b8f66aae5d4c4f45bf2cbdb4683897d5753577e5fbb449
@@ -22,15 +22,15 @@ module GlobalRegistry #:nodoc:
22
22
  else
23
23
  create_entity_in_global_registry
24
24
  end
25
- rescue RestClient::ResourceNotFound
26
- global_registry_entity.id_value = nil
27
- push_entity_to_global_registry
28
25
  end
29
26
 
30
27
  def update_entity_in_global_registry
31
28
  entity_attributes = { global_registry_entity.type => model.entity_attributes_to_push }
32
29
  GlobalRegistry::Entity.put(global_registry_entity.id_value, entity: entity_attributes)
33
30
  update_fingerprint
31
+ rescue RestClient::ResourceNotFound
32
+ global_registry_entity.id_value = nil
33
+ create_entity_in_global_registry
34
34
  end
35
35
 
36
36
  def create_entity_in_global_registry
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GlobalRegistry #:nodoc:
4
4
  module Bindings #:nodoc:
5
- VERSION = '0.3.2'
5
+ VERSION = '0.3.3'
6
6
  end
7
7
  end
@@ -246,14 +246,16 @@ RSpec.describe GlobalRegistry::Bindings::Workers::PushEntityWorker do
246
246
  end
247
247
 
248
248
  context 'invalid entity id' do
249
- let!(:requests) do
250
- [stub_request(:put,
251
- 'https://backend.global-registry.org/entities/f8d20318-2ff2-4a98-a5eb-e9d840508bf1')
249
+ let!(:requests) { [update_request, create_request] }
250
+ let!(:update_request) do
251
+ stub_request(:put, 'https://backend.global-registry.org/entities/f8d20318-2ff2-4a98-a5eb-e9d840508bf1')
252
+ .with(body: entity_body)
253
+ .to_return(status: 404)
254
+ end
255
+ let!(:create_request) do
256
+ stub_request(:post, 'https://backend.global-registry.org/entities')
252
257
  .with(body: entity_body)
253
- .to_return(status: 404),
254
- stub_request(:post, 'https://backend.global-registry.org/entities')
255
- .with(body: entity_body)
256
- .to_return(body: file_fixture('post_entities_person.json'), status: 200)]
258
+ .to_return(body: file_fixture('post_entities_person.json'), status: 200)
257
259
  end
258
260
 
259
261
  it 'should push entity as create' do
@@ -262,6 +264,18 @@ RSpec.describe GlobalRegistry::Bindings::Workers::PushEntityWorker do
262
264
  expect(person.global_registry_id).to eq '22527d88-3cba-11e7-b876-129bd0521531'
263
265
  expect(person.global_registry_fingerprint).to eq '4c671c203b5dd19cdc1920ba5434cf64'
264
266
  end
267
+
268
+ context 'response is also not found on create' do
269
+ let!(:create_request) do
270
+ stub_request(:post, 'https://backend.global-registry.org/entities')
271
+ .with(body: entity_body)
272
+ .to_return(status: 404)
273
+ end
274
+
275
+ it 'should raise an error' do
276
+ expect { worker.push_entity_to_global_registry }.to raise_error(RestClient::NotFound)
277
+ end
278
+ end
265
279
  end
266
280
 
267
281
  context 'fingerprints match' do
@@ -446,17 +460,29 @@ RSpec.describe GlobalRegistry::Bindings::Workers::PushEntityWorker do
446
460
  client_integration_id: address.id,
447
461
  client_updated_at: '2001-02-03 00:00:00'
448
462
  } } } })
449
- .to_return(body: file_fixture('put_entities_address.json'), status: 200)
463
+ .to_return(response)
450
464
  end
465
+ let!(:response) { { body: file_fixture('put_entities_address.json'), status: 200 } }
451
466
 
452
- it 'should push address entity' do
467
+ subject do
453
468
  address.address1 = '100 Sesame Street'
454
469
  address.primary = false
455
- expect do
456
- worker.push_entity_to_global_registry
457
- end.to_not(change { address.global_registry_id })
470
+ worker.push_entity_to_global_registry
471
+ end
472
+
473
+ it 'should push address entity' do
474
+ expect { subject }.to_not(change { address.global_registry_id })
458
475
  expect(request).to have_been_requested.once
459
476
  end
477
+
478
+ context 'response not found' do
479
+ let!(:response) { { status: 404 } }
480
+
481
+ it 'should raise an error' do
482
+ expect { subject }.to raise_error(RestClient::NotFound)
483
+ expect(request).to have_been_requested.once
484
+ end
485
+ end
460
486
  end
461
487
  end
462
488
 
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Zoetewey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-04 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord