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,108 +2,122 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
RSpec.describe
|
6
|
-
describe ':
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
RSpec.describe Organization do
|
6
|
+
describe 'after_commit on: :create' do
|
7
|
+
context 'without parent' do
|
8
|
+
it 'should enqueue sidekiq jobs' do
|
9
|
+
organization = build(:organization)
|
10
|
+
expect do
|
11
|
+
organization.save
|
12
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
|
13
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
14
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
15
|
+
)
|
16
|
+
)
|
17
|
+
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
context 'with area' do
|
20
|
+
it 'should enqueue sidekiq jobs' do
|
21
|
+
area = build(:area)
|
22
|
+
organization = build(:organization, area: area)
|
23
|
+
expect do
|
24
|
+
organization.save
|
25
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(2).and(
|
26
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
|
27
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
28
|
+
)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
22
33
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
organization
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
context 'with parent' do
|
35
|
+
it 'should enqueue sidekiq jobs' do
|
36
|
+
parent = build(:organization)
|
37
|
+
organization = build(:organization, parent: parent)
|
38
|
+
expect do
|
39
|
+
organization.save
|
40
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(2).and(
|
41
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
42
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
43
|
+
)
|
44
|
+
)
|
45
|
+
end
|
30
46
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
.with(body: { entity_type: { name: 'name', parent_id: '025a1128-3f33-11e7-b876-129bd0521531',
|
44
|
-
field_type: 'string' } })
|
45
|
-
.to_return(status: 200),
|
46
|
-
stub_request(:post, 'https://backend.global-registry.org/entity_types')
|
47
|
-
.with(body: { entity_type: { name: 'description', parent_id: '025a1128-3f33-11e7-b876-129bd0521531',
|
48
|
-
field_type: 'string' } })
|
49
|
-
.to_return(status: 200),
|
50
|
-
stub_request(:post, 'https://backend.global-registry.org/entity_types')
|
51
|
-
.with(body: { entity_type: { name: 'start_date', parent_id: '025a1128-3f33-11e7-b876-129bd0521531',
|
52
|
-
field_type: 'date' } })
|
53
|
-
.to_return(status: 200)]
|
47
|
+
context 'with area' do
|
48
|
+
it 'should enqueue sidekiq jobs' do
|
49
|
+
area = build(:area)
|
50
|
+
parent = build(:organization)
|
51
|
+
organization = build(:organization, area: area, parent: parent)
|
52
|
+
expect do
|
53
|
+
organization.save
|
54
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(3).and(
|
55
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
|
56
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
57
|
+
)
|
58
|
+
)
|
54
59
|
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
(requests + sub_requests).each { |r| expect(r).to have_been_requested.once }
|
70
|
-
expect(organization.gr_id).to eq 'aebb4170-3f34-11e7-bba6-129bd0521531'
|
71
|
-
end
|
72
|
-
end
|
64
|
+
describe 'after_commit on: :destroy' do
|
65
|
+
context 'without parent' do
|
66
|
+
it 'should enqueue sidekiq jobs' do
|
67
|
+
organization = create(:organization, gr_id: 'abc')
|
68
|
+
clear_sidekiq_jobs_and_locks
|
69
|
+
expect do
|
70
|
+
organization.destroy
|
71
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
|
72
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
73
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(1)
|
74
|
+
)
|
75
|
+
)
|
76
|
+
end
|
73
77
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
context 'with area' do
|
79
|
+
it 'should enqueue sidekiq jobs' do
|
80
|
+
area = create(:area, global_registry_id: 'efg')
|
81
|
+
organization = create(:organization, area: area, gr_id: 'abc', global_registry_area_id: 'ijk')
|
82
|
+
clear_sidekiq_jobs_and_locks
|
83
|
+
expect do
|
84
|
+
organization.destroy
|
85
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
|
86
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
87
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(2)
|
88
|
+
)
|
89
|
+
)
|
83
90
|
end
|
91
|
+
end
|
92
|
+
end
|
84
93
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
.to_return(body: file_fixture('post_entities_fancy_org.json'), status: 200)]
|
99
|
-
end
|
94
|
+
context 'with parent' do
|
95
|
+
it 'should enqueue sidekiq jobs' do
|
96
|
+
parent = create(:organization, gr_id: 'xyz')
|
97
|
+
organization = create(:organization, parent: parent, gr_id: 'abc')
|
98
|
+
clear_sidekiq_jobs_and_locks
|
99
|
+
expect do
|
100
|
+
organization.destroy
|
101
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
|
102
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
103
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(1)
|
104
|
+
)
|
105
|
+
)
|
106
|
+
end
|
100
107
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
108
|
+
context 'with area' do
|
109
|
+
it 'should enqueue sidekiq jobs' do
|
110
|
+
area = create(:area, global_registry_id: 'efg')
|
111
|
+
parent = create(:organization, gr_id: 'xyz')
|
112
|
+
organization = create(:organization, area: area, gr_id: 'abc', global_registry_area_id: 'ijk', parent: parent)
|
113
|
+
clear_sidekiq_jobs_and_locks
|
114
|
+
expect do
|
115
|
+
organization.destroy
|
116
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
|
117
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
118
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(2)
|
119
|
+
)
|
120
|
+
)
|
107
121
|
end
|
108
122
|
end
|
109
123
|
end
|
data/spec/models/person_spec.rb
CHANGED
@@ -2,245 +2,189 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
RSpec.describe
|
6
|
-
describe ':
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
person.delete_entity_from_global_registry_async
|
20
|
-
end.to change(GlobalRegistry::Bindings::Workers::DeleteGrEntityWorker.jobs, :size).by(1)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should not enqueue sidekiq job when missing global_registry_id' do
|
24
|
-
person = build(:person)
|
25
|
-
expect do
|
26
|
-
person.delete_entity_from_global_registry_async
|
27
|
-
end.not_to change(GlobalRegistry::Bindings::Workers::DeleteGrEntityWorker.jobs, :size)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ':push_entity_to_global_registry' do
|
32
|
-
context 'create' do
|
33
|
-
let(:person) { create(:person) }
|
34
|
-
|
35
|
-
context '\'person\' entity_type does not exist' do
|
36
|
-
around { |example| travel_to Time.utc(2001, 2, 3), &example }
|
37
|
-
let!(:requests) do
|
38
|
-
[stub_request(:get, 'https://backend.global-registry.org/entity_types')
|
39
|
-
.with(query: { 'filters[name]' => 'person', 'filters[parent_id]' => nil })
|
40
|
-
.to_return(body: file_fixture('get_entity_types.json'), status: 200),
|
41
|
-
stub_request(:post, 'https://backend.global-registry.org/entity_types')
|
42
|
-
.with(body: { entity_type: { name: 'person', parent_id: nil, field_type: 'entity' } })
|
43
|
-
.to_return(body: file_fixture('post_entity_types_person.json'), status: 200),
|
44
|
-
stub_request(:post, 'https://backend.global-registry.org/entity_types')
|
45
|
-
.with(body: { entity_type: { name: 'first_name', parent_id: 'ee13a693-3ce7-4c19-b59a-30c8f137acd8',
|
46
|
-
field_type: 'string' } })
|
47
|
-
.to_return(status: 200),
|
48
|
-
stub_request(:post, 'https://backend.global-registry.org/entity_types')
|
49
|
-
.with(body: { entity_type: { name: 'last_name', parent_id: 'ee13a693-3ce7-4c19-b59a-30c8f137acd8',
|
50
|
-
field_type: 'string' } })
|
51
|
-
.to_return(status: 200),
|
52
|
-
stub_request(:post, 'https://backend.global-registry.org/entities')
|
53
|
-
.with(body: { entity: { person: { first_name: 'Tony', last_name: 'Stark',
|
54
|
-
client_integration_id: person.id,
|
55
|
-
client_updated_at: '2001-02-03 00:00:00',
|
56
|
-
authentication: {
|
57
|
-
key_guid: '98711710-acb5-4a41-ba51-e0fc56644b53'
|
58
|
-
} } } })
|
59
|
-
.to_return(body: file_fixture('post_entities_person.json'), status: 200)]
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should create \'person\' entity_type and push entity' do
|
63
|
-
person.push_entity_to_global_registry
|
64
|
-
requests.each { |r| expect(r).to have_been_requested.once }
|
65
|
-
expect(person.global_registry_id).to eq '22527d88-3cba-11e7-b876-129bd0521531'
|
66
|
-
end
|
5
|
+
RSpec.describe Namespaced::Person do
|
6
|
+
describe 'after_commit on: :create' do
|
7
|
+
context 'without associations' do
|
8
|
+
it 'should enqueue sidekiq jobs' do
|
9
|
+
person = build(:person)
|
10
|
+
expect do
|
11
|
+
person.save
|
12
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
|
13
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
14
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
15
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
16
|
+
)
|
17
|
+
)
|
18
|
+
)
|
67
19
|
end
|
20
|
+
end
|
68
21
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
.to_return(body: file_fixture('post_entities_person.json'), status: 200)]
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should skip creating entity_type and push the entity' do
|
86
|
-
person.push_entity_to_global_registry
|
87
|
-
requests.each { |r| expect(r).to have_been_requested.once }
|
88
|
-
expect(person.global_registry_id).to eq '22527d88-3cba-11e7-b876-129bd0521531'
|
89
|
-
end
|
22
|
+
context 'with country_of_service' do
|
23
|
+
it 'should enqueue sidekiq jobs' do
|
24
|
+
country = build(:country)
|
25
|
+
person = build(:person, country_of_service: country)
|
26
|
+
expect do
|
27
|
+
person.save
|
28
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(2).and(
|
29
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
30
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
|
31
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
32
|
+
)
|
33
|
+
)
|
34
|
+
)
|
90
35
|
end
|
36
|
+
end
|
91
37
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
client_updated_at: '2001-02-03 00:00:00',
|
106
|
-
authentication: {
|
107
|
-
key_guid: '98711710-acb5-4a41-ba51-e0fc56644b53'
|
108
|
-
} } } })
|
109
|
-
.to_return(body: file_fixture('post_entities_person.json'), status: 200)]
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should skip creating entity_type and push the entity' do
|
113
|
-
person.push_entity_to_global_registry
|
114
|
-
requests.each { |r| expect(r).to have_been_requested.once }
|
115
|
-
expect(person.global_registry_id).to eq '22527d88-3cba-11e7-b876-129bd0521531'
|
116
|
-
end
|
38
|
+
context 'with country_of_residence' do
|
39
|
+
it 'should enqueue sidekiq jobs' do
|
40
|
+
country = build(:country)
|
41
|
+
person = build(:person, country_of_residence: country)
|
42
|
+
expect do
|
43
|
+
person.save
|
44
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(2).and(
|
45
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
46
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
|
47
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
48
|
+
)
|
49
|
+
)
|
50
|
+
)
|
117
51
|
end
|
52
|
+
end
|
118
53
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
key_guid: '98711710-acb5-4a41-ba51-e0fc56644b53'
|
133
|
-
} } } })
|
134
|
-
.to_return(body: file_fixture('post_entities_person.json'), status: 200)
|
135
|
-
person.push_entity_to_global_registry
|
136
|
-
expect(request).to have_been_requested.once
|
137
|
-
expect(person.global_registry_id).to eq '22527d88-3cba-11e7-b876-129bd0521531'
|
138
|
-
end
|
54
|
+
context 'with country_of_service and country_of_residence' do
|
55
|
+
it 'should enqueue sidekiq jobs' do
|
56
|
+
country = build(:country)
|
57
|
+
person = build(:person, country_of_residence: country, country_of_service: country)
|
58
|
+
expect do
|
59
|
+
person.save
|
60
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(2).and(
|
61
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
62
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(2).and(
|
63
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
64
|
+
)
|
65
|
+
)
|
66
|
+
)
|
139
67
|
end
|
140
68
|
end
|
69
|
+
end
|
141
70
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
71
|
+
describe 'after_commit on: :update' do
|
72
|
+
context 'update person attribute' do
|
73
|
+
it 'should enqueue sidekiq jobs' do
|
74
|
+
person = create(:person, global_registry_id: 'dd555dbf-f3db-4158-a50c-50d3f26347e8')
|
75
|
+
clear_sidekiq_jobs_and_locks
|
76
|
+
expect do
|
77
|
+
person.first_name = 'Anthony'
|
78
|
+
person.save
|
79
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
|
80
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
81
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
82
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
83
|
+
)
|
84
|
+
)
|
85
|
+
)
|
86
|
+
end
|
150
87
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
88
|
+
context 'with associations' do
|
89
|
+
it 'should enqueue sidekiq jobs' do
|
90
|
+
country = create(:country)
|
91
|
+
person = create(:person, country_of_residence: country, country_of_service: country)
|
92
|
+
clear_sidekiq_jobs_and_locks
|
93
|
+
expect do
|
94
|
+
person.first_name = 'Anthony'
|
95
|
+
person.save
|
96
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
|
97
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
98
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(2).and(
|
99
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
100
|
+
)
|
101
|
+
)
|
102
|
+
)
|
163
103
|
end
|
164
104
|
|
165
|
-
context '
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
.
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
key_guid: '98711710-acb5-4a41-ba51-e0fc56644b53'
|
182
|
-
} } } })
|
183
|
-
.to_return(body: file_fixture('post_entities_person.json'), status: 200)]
|
105
|
+
context 'country_of_residence removed' do
|
106
|
+
it 'should enqueue sidekiq jobs' do
|
107
|
+
country = create(:country)
|
108
|
+
person = create(:person, country_of_residence: country, country_of_service: country,
|
109
|
+
country_of_residence_gr_id: '4fa555dd-a067-478e-8765-8faa9483cc56')
|
110
|
+
clear_sidekiq_jobs_and_locks
|
111
|
+
expect do
|
112
|
+
person.country_of_residence = nil
|
113
|
+
person.save
|
114
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
|
115
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
116
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
|
117
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(1)
|
118
|
+
)
|
119
|
+
)
|
120
|
+
)
|
184
121
|
end
|
122
|
+
end
|
185
123
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
124
|
+
context 'country_of_service changed' do
|
125
|
+
it 'should enqueue sidekiq jobs' do
|
126
|
+
country = create(:country, global_registry_id: 'f078eb70-5ddd-4941-9b06-a39576d9952f')
|
127
|
+
country2 = create(:country, name: 'Peru', global_registry_id: 'f078eb70-5ddd-4941-9b06-a39576d9963c')
|
128
|
+
person = create(:person, country_of_residence: country, country_of_service: country,
|
129
|
+
country_of_residence_gr_id: '4fa555dd-a067-478e-8765-8faa9483cc56',
|
130
|
+
country_of_service_gr_id: '89f81f6e-7baf-44d9-8f3a-55bf7c652dcc')
|
131
|
+
request = stub_request(:delete,
|
132
|
+
'https://backend.global-registry.org/entities/89f81f6e-7baf-44d9-8f3a-55bf7c652dcc')
|
133
|
+
.to_return(status: 200)
|
134
|
+
|
135
|
+
clear_sidekiq_jobs_and_locks
|
136
|
+
expect do
|
137
|
+
person.country_of_service = country2
|
138
|
+
person.save
|
139
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
|
140
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
|
141
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(2).and(
|
142
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
|
143
|
+
)
|
144
|
+
)
|
145
|
+
)
|
146
|
+
expect(request).to have_been_requested.once
|
190
147
|
end
|
191
148
|
end
|
192
149
|
end
|
193
150
|
end
|
194
151
|
end
|
195
152
|
|
196
|
-
describe ':
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end.to change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe ':pull_mdm_id_from_global_registry' do
|
206
|
-
context 'record missing global_registry_id' do
|
207
|
-
let(:person) { create(:person) }
|
208
|
-
|
209
|
-
it 'should raise an exception' do
|
153
|
+
describe 'after_commit on: :destroy' do
|
154
|
+
context 'without associations' do
|
155
|
+
it 'should enqueue sidekiq jobs' do
|
156
|
+
person = create(:person, global_registry_id: 'dd555dbf-f3db-4158-a50c-50d3f26347e8')
|
157
|
+
clear_sidekiq_jobs_and_locks
|
210
158
|
expect do
|
211
|
-
person.
|
212
|
-
end.to
|
159
|
+
person.destroy
|
160
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
|
161
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(0).and(
|
162
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
163
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(1)
|
164
|
+
)
|
165
|
+
)
|
166
|
+
)
|
213
167
|
end
|
214
168
|
end
|
215
169
|
|
216
|
-
context '
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
expect do
|
226
|
-
person.pull_mdm_id_from_global_registry
|
227
|
-
end.to raise_error GlobalRegistry::Bindings::EntityMissingMdmId
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
context 'entity missing mdm id' do
|
232
|
-
let(:person) { create(:person, global_registry_id: '22527d88-3cba-11e7-b876-129bd0521531') }
|
233
|
-
let!(:request) do
|
234
|
-
stub_request(:get, 'https://backend.global-registry.org/entities/22527d88-3cba-11e7-b876-129bd0521531')
|
235
|
-
.with(query: { 'filters[owned_by]' => 'mdm' })
|
236
|
-
.to_return(body: file_fixture('get_entities_person_mdm.json'), status: 200)
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'should raise an exception' do
|
170
|
+
context 'with associations' do
|
171
|
+
it 'should enqueue sidekiq jobs' do
|
172
|
+
resident = create(:country, global_registry_id: 'f078eb70-5ddd-4941-9b06-a39576d9952f')
|
173
|
+
employee = create(:country, global_registry_id: 'f078eb70-5ddd-4941-9b06-a39576d99639')
|
174
|
+
person = create(:person, country_of_residence: resident, country_of_service: employee,
|
175
|
+
global_registry_id: 'dd555dbf-f3db-4158-a50c-50d3f26347e8',
|
176
|
+
country_of_residence_gr_id: '4fa555dd-a067-478e-8765-8faa9483cc56',
|
177
|
+
country_of_service_gr_id: '89f81f6e-7baf-44d9-8f3a-55bf7c652dcc')
|
178
|
+
clear_sidekiq_jobs_and_locks
|
240
179
|
expect do
|
241
|
-
person.
|
242
|
-
|
243
|
-
|
180
|
+
person.destroy
|
181
|
+
end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
|
182
|
+
change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(0).and(
|
183
|
+
change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
|
184
|
+
change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(3)
|
185
|
+
)
|
186
|
+
)
|
187
|
+
)
|
244
188
|
end
|
245
189
|
end
|
246
190
|
end
|