global-registry-bindings 0.6.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/global_registry_bindings/entity/entity_type_methods.rb +16 -18
  3. data/lib/global_registry_bindings/entity/mdm_methods.rb +11 -12
  4. data/lib/global_registry_bindings/entity/push_entity_methods.rb +23 -23
  5. data/lib/global_registry_bindings/entity/push_relationship_methods.rb +18 -18
  6. data/lib/global_registry_bindings/entity/relationship_type_methods.rb +26 -26
  7. data/lib/global_registry_bindings/exceptions.rb +7 -2
  8. data/lib/global_registry_bindings/global_registry_bindings.rb +19 -19
  9. data/lib/global_registry_bindings/model/delete_entity.rb +4 -4
  10. data/lib/global_registry_bindings/model/entity.rb +25 -25
  11. data/lib/global_registry_bindings/model/pull_mdm.rb +5 -5
  12. data/lib/global_registry_bindings/model/push_entity.rb +4 -4
  13. data/lib/global_registry_bindings/model/push_relationship.rb +12 -10
  14. data/lib/global_registry_bindings/model/relationship.rb +18 -18
  15. data/lib/global_registry_bindings/options/entity_class_options.rb +15 -15
  16. data/lib/global_registry_bindings/options/entity_instance_options.rb +11 -11
  17. data/lib/global_registry_bindings/options/entity_options_parser.rb +3 -3
  18. data/lib/global_registry_bindings/options/relationship_class_options.rb +22 -22
  19. data/lib/global_registry_bindings/options/relationship_instance_options.rb +12 -12
  20. data/lib/global_registry_bindings/options/relationship_options_parser.rb +7 -7
  21. data/lib/global_registry_bindings/options.rb +6 -6
  22. data/lib/global_registry_bindings/railtie.rb +7 -7
  23. data/lib/global_registry_bindings/testing.rb +3 -3
  24. data/lib/global_registry_bindings/version.rb +3 -3
  25. data/lib/global_registry_bindings/worker.rb +5 -5
  26. data/lib/global_registry_bindings/workers/delete_entity_worker.rb +3 -3
  27. data/lib/global_registry_bindings/workers/pull_mdm_id_worker.rb +5 -5
  28. data/lib/global_registry_bindings/workers/push_entity_worker.rb +6 -6
  29. data/lib/global_registry_bindings/workers/push_relationship_worker.rb +6 -6
  30. data/lib/global_registry_bindings.rb +3 -3
  31. metadata +16 -156
  32. data/spec/acceptance/global_registry_bindings_spec.rb +0 -191
  33. data/spec/factories/factories.rb +0 -72
  34. data/spec/fixtures/get_entities_person.json +0 -8
  35. data/spec/fixtures/get_entities_person_mdm.json +0 -13
  36. data/spec/fixtures/get_entities_person_relationship.json +0 -32
  37. data/spec/fixtures/get_entity_types.json +0 -9
  38. data/spec/fixtures/get_entity_types_address.json +0 -59
  39. data/spec/fixtures/get_entity_types_address_partial.json +0 -43
  40. data/spec/fixtures/get_entity_types_area.json +0 -44
  41. data/spec/fixtures/get_entity_types_community.json +0 -18
  42. data/spec/fixtures/get_entity_types_fancy_org.json +0 -43
  43. data/spec/fixtures/get_entity_types_fancy_org_assignment.json +0 -35
  44. data/spec/fixtures/get_entity_types_fancy_org_partial.json +0 -35
  45. data/spec/fixtures/get_entity_types_ministry.json +0 -18
  46. data/spec/fixtures/get_entity_types_person.json +0 -42
  47. data/spec/fixtures/get_entity_types_person_partial.json +0 -34
  48. data/spec/fixtures/get_relationship_types.json +0 -9
  49. data/spec/fixtures/get_relationship_types_person_fancy_org.json +0 -41
  50. data/spec/fixtures/get_relationship_types_person_fancy_org_partial.json +0 -33
  51. data/spec/fixtures/post_entities_community.json +0 -8
  52. data/spec/fixtures/post_entities_fancy_org.json +0 -8
  53. data/spec/fixtures/post_entities_fancy_org_parent.json +0 -8
  54. data/spec/fixtures/post_entities_person.json +0 -8
  55. data/spec/fixtures/post_entity_types_address.json +0 -9
  56. data/spec/fixtures/post_entity_types_fancy_org.json +0 -9
  57. data/spec/fixtures/post_entity_types_person.json +0 -9
  58. data/spec/fixtures/post_relationship_types_assigned_by.json +0 -16
  59. data/spec/fixtures/post_relationship_types_community_ministry.json +0 -16
  60. data/spec/fixtures/post_relationship_types_fancy_org_area.json +0 -16
  61. data/spec/fixtures/post_relationship_types_person_fancy_org.json +0 -16
  62. data/spec/fixtures/put_entities_address.json +0 -20
  63. data/spec/fixtures/put_entities_community_relationship.json +0 -16
  64. data/spec/fixtures/put_entities_fancy_org_area_relationship.json +0 -8
  65. data/spec/fixtures/put_entities_fancy_org_assignment_assigned_by.json +0 -20
  66. data/spec/fixtures/put_entities_fancy_org_relationship.json +0 -17
  67. data/spec/fixtures/put_entities_person_country_relationship.json +0 -23
  68. data/spec/fixtures/put_entities_person_relationship.json +0 -29
  69. data/spec/fixtures/put_entities_relationship.json +0 -8
  70. data/spec/fixtures/put_entities_relationship_400.json +0 -3
  71. data/spec/fixtures/put_relationship_types_fields.json +0 -33
  72. data/spec/fixtures/put_relationship_types_fields_fancy_org_area.json +0 -25
  73. data/spec/helpers/sidekiq_helpers.rb +0 -14
  74. data/spec/internal/app/models/address.rb +0 -17
  75. data/spec/internal/app/models/application_record.rb +0 -5
  76. data/spec/internal/app/models/area.rb +0 -7
  77. data/spec/internal/app/models/assignment.rb +0 -21
  78. data/spec/internal/app/models/community.rb +0 -20
  79. data/spec/internal/app/models/country.rb +0 -8
  80. data/spec/internal/app/models/default.rb +0 -6
  81. data/spec/internal/app/models/namespaced/person/user_edited.rb +0 -8
  82. data/spec/internal/app/models/namespaced/person.rb +0 -68
  83. data/spec/internal/app/models/organization.rb +0 -37
  84. data/spec/internal/config/database.yml +0 -4
  85. data/spec/internal/config/initializers/global_registry.rb +0 -8
  86. data/spec/internal/config/routes.rb +0 -5
  87. data/spec/internal/db/schema.rb +0 -75
  88. data/spec/internal/db/test.sqlite +0 -0
  89. data/spec/internal/log/test.log +0 -1457
  90. data/spec/models/address_spec.rb +0 -30
  91. data/spec/models/assignment_spec.rb +0 -54
  92. data/spec/models/organization_spec.rb +0 -125
  93. data/spec/models/person_spec.rb +0 -191
  94. data/spec/models/testing_spec.rb +0 -55
  95. data/spec/models/user_edited_person_spec.rb +0 -14
  96. data/spec/options/if_unless_spec.rb +0 -147
  97. data/spec/spec_helper.rb +0 -52
  98. data/spec/workers/delete_gr_entity_worker_spec.rb +0 -33
  99. data/spec/workers/pull_mdm_id_worker_spec.rb +0 -133
  100. data/spec/workers/push_entity_worker_spec.rb +0 -506
  101. data/spec/workers/push_relationship_worker_spec.rb +0 -503
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Address do
6
- describe '#push_entity_to_global_registry_async' do
7
- it 'should enqueue sidekiq job' do
8
- address = build(:address)
9
- expect do
10
- address.push_entity_to_global_registry_async
11
- end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1)
12
- end
13
- end
14
-
15
- describe '#delete_entity_from_global_registry_async' do
16
- it 'should enqueue sidekiq job' do
17
- address = build(:address, global_registry_id: '22527d88-3cba-11e7-b876-129bd0521531')
18
- expect do
19
- address.delete_entity_from_global_registry_async
20
- end.to change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(1)
21
- end
22
-
23
- it 'should not enqueue sidekiq job when missing global_registry_id' do
24
- address = build(:address)
25
- expect do
26
- address.delete_entity_from_global_registry_async
27
- end.not_to change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size)
28
- end
29
- end
30
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Assignment do
6
- describe 'after_commit on: :create' do
7
- it 'should enqueue sidekiq job' do
8
- person = create(:person)
9
- organization = create(:organization)
10
- assignment = build(:assignment, person: person, organization: organization)
11
- clear_sidekiq_jobs_and_locks
12
- expect do
13
- assignment.save
14
- end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
15
- change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
16
- change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
17
- )
18
- )
19
- end
20
- end
21
-
22
- describe 'after_commit on: :update' do
23
- it 'should enqueue sidekiq job' do
24
- person = create(:person)
25
- organization = create(:organization)
26
- assignment = create(:assignment, person: person, organization: organization)
27
- clear_sidekiq_jobs_and_locks
28
- expect do
29
- assignment.role = 'boss'
30
- assignment.save
31
- end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
32
- change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(1).and(
33
- change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
34
- )
35
- )
36
- end
37
- end
38
-
39
- describe 'after_commit on: :destroy' do
40
- it 'should enqueue sidekiq job' do
41
- person = create(:person)
42
- organization = create(:organization)
43
- assignment = create(:assignment, person: person, organization: organization, global_registry_id: 'abc')
44
- clear_sidekiq_jobs_and_locks
45
- expect do
46
- assignment.destroy
47
- end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(0).and(
48
- change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
49
- change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(1)
50
- )
51
- )
52
- end
53
- end
54
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
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
18
-
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
32
- end
33
-
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
46
-
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
- )
59
- end
60
- end
61
- end
62
- end
63
-
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
77
-
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
- )
90
- end
91
- end
92
- end
93
-
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
107
-
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
- )
121
- end
122
- end
123
- end
124
- end
125
- end
@@ -1,191 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
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
- )
19
- end
20
- end
21
-
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
- )
35
- end
36
- end
37
-
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
- )
51
- end
52
- end
53
-
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
- )
67
- end
68
- end
69
- end
70
-
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
87
-
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
- )
103
- end
104
-
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
- )
121
- end
122
- end
123
-
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
147
- end
148
- end
149
- end
150
- end
151
- end
152
-
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
158
- expect do
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
- )
167
- end
168
- end
169
-
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
179
- expect do
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
- )
188
- end
189
- end
190
- end
191
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe GlobalRegistry::Bindings::Testing do
6
- describe 'skip_workers! &block' do
7
- around(:example) do |example|
8
- GlobalRegistry::Bindings::Testing.skip_workers!(&example)
9
- end
10
-
11
- it 'should not enqueue sidekiq jobs' do
12
- person = build(:person)
13
- expect do
14
- person.save
15
- end.to change(Sidekiq::Worker.jobs, :size).by(0)
16
- end
17
-
18
- context 'disable_test_helper! &block' do
19
- it 'should enqueue sidekiq jobs' do
20
- expect(GlobalRegistry::Bindings::Testing.enabled?).to be true
21
- GlobalRegistry::Bindings::Testing.disable_test_helper! do
22
- expect(GlobalRegistry::Bindings::Testing.enabled?).to be false
23
- expect(GlobalRegistry::Bindings::Testing.disabled?).to be true
24
- person = build(:person)
25
- expect do
26
- person.save
27
- end.to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size).by(1).and(
28
- change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1).and(
29
- change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size).by(0).and(
30
- change(GlobalRegistry::Bindings::Workers::DeleteEntityWorker.jobs, :size).by(0)
31
- )
32
- )
33
- )
34
- end
35
- expect(GlobalRegistry::Bindings::Testing.enabled?).to be true
36
- end
37
- end
38
- end
39
-
40
- describe 'skip_workers! enable/disable' do
41
- before do
42
- GlobalRegistry::Bindings::Testing.skip_workers!
43
- end
44
- after do
45
- GlobalRegistry::Bindings::Testing.disable_test_helper!
46
- end
47
-
48
- it 'should not enqueue sidekiq jobs' do
49
- person = build(:person)
50
- expect do
51
- person.save
52
- end.to change(Sidekiq::Worker.jobs, :size).by(0)
53
- end
54
- end
55
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Namespaced::Person::UserEdited do
6
- describe '#pull_mdm_id_from_global_registry_async' do
7
- it 'should enqueue sidekiq job' do
8
- user_edited = build(:user_edited)
9
- expect do
10
- user_edited.pull_mdm_id_from_global_registry_async
11
- end.to change(GlobalRegistry::Bindings::Workers::PullNamespacedPersonMdmIdWorker.jobs, :size).by(1)
12
- end
13
- end
14
- end
@@ -1,147 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'Options' do
6
- before do
7
- stub_const 'Foo', Class.new(::ApplicationRecord)
8
- end
9
-
10
- describe 'entity' do
11
- describe ':if' do
12
- context 'value as proc' do
13
- before do
14
- Foo.class_eval { global_registry_bindings type: :foo, if: proc { |_model| true } }
15
- end
16
-
17
- it 'should not enqueue sidekiq job' do
18
- foo = Foo.new
19
- expect do
20
- foo.save
21
- end.not_to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size)
22
- end
23
- end
24
-
25
- context 'value as symbol' do
26
- before do
27
- Foo.class_eval { global_registry_bindings type: :foo, if: :if_cond }
28
- Foo.class_eval do
29
- def if_cond(_model)
30
- true
31
- end
32
- end
33
- end
34
-
35
- it 'should not enqueue sidekiq job' do
36
- foo = Foo.new
37
- expect do
38
- foo.save
39
- end.not_to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size)
40
- end
41
- end
42
- end
43
-
44
- describe ':unless' do
45
- context 'value as proc' do
46
- before do
47
- Foo.class_eval { global_registry_bindings type: :foo, unless: proc { |_model| false } }
48
- end
49
-
50
- it 'should not enqueue sidekiq job' do
51
- foo = Foo.new
52
- expect do
53
- foo.save
54
- end.not_to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size)
55
- end
56
- end
57
-
58
- context 'value as symbol' do
59
- before do
60
- Foo.class_eval { global_registry_bindings type: :foo, unless: :unless_cond }
61
- Foo.class_eval do
62
- def unless_cond(_model)
63
- false
64
- end
65
- end
66
- end
67
-
68
- it 'should not enqueue sidekiq job' do
69
- foo = Foo.new
70
- expect do
71
- foo.save
72
- end.not_to change(GlobalRegistry::Bindings::Workers::PushEntityWorker.jobs, :size)
73
- end
74
- end
75
- end
76
- end
77
-
78
- describe 'relationship' do
79
- describe ':if' do
80
- context 'value as proc' do
81
- before do
82
- Foo.class_eval { global_registry_bindings binding: :relationship, type: :foo, if: proc { |_model| true } }
83
- end
84
-
85
- it 'should not enqueue sidekiq job' do
86
- foo = Foo.new
87
- expect do
88
- foo.save
89
- end.not_to change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size)
90
- end
91
- end
92
-
93
- context 'value as symbol' do
94
- before do
95
- Foo.class_eval { global_registry_bindings binding: :relationship, type: :foo, if: :if_cond }
96
- Foo.class_eval do
97
- def if_cond(_type, _model)
98
- true
99
- end
100
- end
101
- end
102
-
103
- it 'should not enqueue sidekiq job' do
104
- foo = Foo.new
105
- expect do
106
- foo.save
107
- end.not_to change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size)
108
- end
109
- end
110
- end
111
-
112
- describe ':unless' do
113
- context 'value as proc' do
114
- before do
115
- Foo.class_eval do
116
- global_registry_bindings binding: :relationship, type: :foo, unless: proc { |_model| false }
117
- end
118
- end
119
-
120
- it 'should not enqueue sidekiq job' do
121
- foo = Foo.new
122
- expect do
123
- foo.save
124
- end.not_to change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size)
125
- end
126
- end
127
-
128
- context 'value as symbol' do
129
- before do
130
- Foo.class_eval { global_registry_bindings binding: :relationship, type: :foo, unless: :unless_cond }
131
- Foo.class_eval do
132
- def unless_cond(_type, _model)
133
- false
134
- end
135
- end
136
- end
137
-
138
- it 'should not enqueue sidekiq job' do
139
- foo = Foo.new
140
- expect do
141
- foo.save
142
- end.not_to change(GlobalRegistry::Bindings::Workers::PushRelationshipWorker.jobs, :size)
143
- end
144
- end
145
- end
146
- end
147
- end
data/spec/spec_helper.rb DELETED
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler/setup'
5
- require 'pry'
6
-
7
- require 'active_record'
8
- ActiveRecord::Migration.verbose = false
9
-
10
- require 'combustion'
11
- Combustion.initialize! :active_record
12
-
13
- require 'rspec/rails'
14
- require 'webmock/rspec'
15
- require 'factory_girl'
16
- require 'simplecov'
17
-
18
- require 'global_registry_bindings'
19
- require 'global_registry_bindings/testing'
20
-
21
- require 'sidekiq/testing'
22
- require 'sidekiq_unique_jobs/testing'
23
- Sidekiq::Testing.fake!
24
-
25
- require 'mock_redis'
26
- MOCK_REDIS = MockRedis.new
27
-
28
- ActionController::Base.cache_store = :memory_store
29
-
30
- require 'helpers/sidekiq_helpers'
31
-
32
- RSpec.configure do |config|
33
- config.use_transactional_fixtures = true
34
- config.file_fixture_path = 'spec/fixtures'
35
- config.filter_run focus: true
36
- config.run_all_when_everything_filtered = true
37
- config.include ActiveSupport::Testing::TimeHelpers
38
- config.include FactoryGirl::Syntax::Methods
39
- config.include SidekiqHelpers
40
-
41
- config.before(:suite) do
42
- FactoryGirl.find_definitions
43
- end
44
-
45
- config.before(:each) do
46
- allow(Sidekiq).to receive(:redis).and_yield(MOCK_REDIS)
47
-
48
- clear_sidekiq_jobs_and_locks
49
-
50
- Rails.cache.clear
51
- end
52
- end