global-registry-bindings 0.1.9 → 0.2.0

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.
@@ -0,0 +1,147 @@
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
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.9
4
+ version: 0.2.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-10-17 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -402,6 +402,7 @@ files:
402
402
  - spec/models/person_spec.rb
403
403
  - spec/models/testing_spec.rb
404
404
  - spec/models/user_edited_person_spec.rb
405
+ - spec/options/if_unless_spec.rb
405
406
  - spec/spec_helper.rb
406
407
  - spec/workers/delete_gr_entity_worker_spec.rb
407
408
  - spec/workers/pull_mdm_id_worker_spec.rb
@@ -432,71 +433,72 @@ signing_key:
432
433
  specification_version: 4
433
434
  summary: ActiveRecord bindings for Global Registry
434
435
  test_files:
435
- - spec/acceptance/global_registry_bindings_spec.rb
436
- - spec/factories/factories.rb
437
- - spec/fixtures/get_entities_person.json
438
- - spec/fixtures/get_entities_person_mdm.json
439
- - spec/fixtures/get_entities_person_relationship.json
440
- - spec/fixtures/get_entity_types.json
441
- - spec/fixtures/get_entity_types_address.json
442
- - spec/fixtures/get_entity_types_address_partial.json
443
- - spec/fixtures/get_entity_types_area.json
444
- - spec/fixtures/get_entity_types_community.json
445
- - spec/fixtures/get_entity_types_fancy_org.json
446
- - spec/fixtures/get_entity_types_fancy_org_assignment.json
447
- - spec/fixtures/get_entity_types_fancy_org_partial.json
448
- - spec/fixtures/get_entity_types_ministry.json
449
- - spec/fixtures/get_entity_types_person.json
450
- - spec/fixtures/get_entity_types_person_partial.json
451
- - spec/fixtures/get_relationship_types.json
452
- - spec/fixtures/get_relationship_types_person_fancy_org.json
453
- - spec/fixtures/get_relationship_types_person_fancy_org_partial.json
454
- - spec/fixtures/post_entities_community.json
455
- - spec/fixtures/post_entities_fancy_org.json
456
- - spec/fixtures/post_entities_fancy_org_parent.json
457
- - spec/fixtures/post_entities_person.json
458
- - spec/fixtures/post_entity_types_address.json
459
- - spec/fixtures/post_entity_types_fancy_org.json
460
- - spec/fixtures/post_entity_types_person.json
461
- - spec/fixtures/post_relationship_types_assigned_by.json
462
- - spec/fixtures/post_relationship_types_community_ministry.json
463
- - spec/fixtures/post_relationship_types_fancy_org_area.json
464
- - spec/fixtures/post_relationship_types_person_fancy_org.json
465
- - spec/fixtures/put_entities_address.json
466
- - spec/fixtures/put_entities_community_relationship.json
467
- - spec/fixtures/put_entities_fancy_org_area_relationship.json
468
- - spec/fixtures/put_entities_fancy_org_assignment_assigned_by.json
469
- - spec/fixtures/put_entities_fancy_org_relationship.json
470
- - spec/fixtures/put_entities_person_country_relationship.json
471
- - spec/fixtures/put_entities_person_relationship.json
472
- - spec/fixtures/put_entities_relationship.json
473
- - spec/fixtures/put_entities_relationship_400.json
474
- - spec/fixtures/put_relationship_types_fields.json
475
- - spec/fixtures/put_relationship_types_fields_fancy_org_area.json
476
- - spec/helpers/sidekiq_helpers.rb
477
- - spec/internal/app/models/address.rb
478
- - spec/internal/app/models/application_record.rb
436
+ - spec/spec_helper.rb
437
+ - spec/options/if_unless_spec.rb
479
438
  - spec/internal/app/models/area.rb
480
- - spec/internal/app/models/assignment.rb
481
- - spec/internal/app/models/community.rb
482
- - spec/internal/app/models/country.rb
483
- - spec/internal/app/models/default.rb
484
439
  - spec/internal/app/models/namespaced/person/user_edited.rb
485
440
  - spec/internal/app/models/namespaced/person.rb
441
+ - spec/internal/app/models/assignment.rb
442
+ - spec/internal/app/models/default.rb
443
+ - spec/internal/app/models/country.rb
444
+ - spec/internal/app/models/community.rb
486
445
  - spec/internal/app/models/organization.rb
446
+ - spec/internal/app/models/application_record.rb
447
+ - spec/internal/app/models/address.rb
448
+ - spec/internal/config/routes.rb
487
449
  - spec/internal/config/database.yml
488
450
  - spec/internal/config/initializers/global_registry.rb
489
- - spec/internal/config/routes.rb
490
451
  - spec/internal/db/schema.rb
491
452
  - spec/internal/log/test.log
492
- - spec/models/address_spec.rb
493
- - spec/models/assignment_spec.rb
494
- - spec/models/organization_spec.rb
495
453
  - spec/models/person_spec.rb
496
454
  - spec/models/testing_spec.rb
455
+ - spec/models/assignment_spec.rb
456
+ - spec/models/organization_spec.rb
497
457
  - spec/models/user_edited_person_spec.rb
498
- - spec/spec_helper.rb
499
- - spec/workers/delete_gr_entity_worker_spec.rb
500
- - spec/workers/pull_mdm_id_worker_spec.rb
458
+ - spec/models/address_spec.rb
459
+ - spec/acceptance/global_registry_bindings_spec.rb
460
+ - spec/factories/factories.rb
461
+ - spec/fixtures/post_relationship_types_community_ministry.json
462
+ - spec/fixtures/get_entity_types_fancy_org_partial.json
463
+ - spec/fixtures/post_entities_person.json
464
+ - spec/fixtures/get_entity_types_area.json
465
+ - spec/fixtures/post_relationship_types_fancy_org_area.json
466
+ - spec/fixtures/put_entities_person_country_relationship.json
467
+ - spec/fixtures/get_entity_types_person.json
468
+ - spec/fixtures/get_entity_types_community.json
469
+ - spec/fixtures/post_relationship_types_person_fancy_org.json
470
+ - spec/fixtures/get_entity_types_address_partial.json
471
+ - spec/fixtures/get_entity_types_fancy_org_assignment.json
472
+ - spec/fixtures/put_entities_fancy_org_area_relationship.json
473
+ - spec/fixtures/get_entities_person_mdm.json
474
+ - spec/fixtures/put_entities_address.json
475
+ - spec/fixtures/get_entity_types_fancy_org.json
476
+ - spec/fixtures/post_entity_types_address.json
477
+ - spec/fixtures/post_relationship_types_assigned_by.json
478
+ - spec/fixtures/get_entity_types.json
479
+ - spec/fixtures/put_entities_relationship.json
480
+ - spec/fixtures/put_entities_relationship_400.json
481
+ - spec/fixtures/put_entities_fancy_org_assignment_assigned_by.json
482
+ - spec/fixtures/get_relationship_types.json
483
+ - spec/fixtures/post_entity_types_fancy_org.json
484
+ - spec/fixtures/get_entity_types_ministry.json
485
+ - spec/fixtures/get_relationship_types_person_fancy_org.json
486
+ - spec/fixtures/put_entities_person_relationship.json
487
+ - spec/fixtures/post_entities_fancy_org.json
488
+ - spec/fixtures/get_entity_types_address.json
489
+ - spec/fixtures/get_entity_types_person_partial.json
490
+ - spec/fixtures/post_entity_types_person.json
491
+ - spec/fixtures/post_entities_fancy_org_parent.json
492
+ - spec/fixtures/get_entities_person.json
493
+ - spec/fixtures/put_relationship_types_fields_fancy_org_area.json
494
+ - spec/fixtures/put_entities_community_relationship.json
495
+ - spec/fixtures/post_entities_community.json
496
+ - spec/fixtures/get_relationship_types_person_fancy_org_partial.json
497
+ - spec/fixtures/put_relationship_types_fields.json
498
+ - spec/fixtures/get_entities_person_relationship.json
499
+ - spec/fixtures/put_entities_fancy_org_relationship.json
501
500
  - spec/workers/push_entity_worker_spec.rb
502
501
  - spec/workers/push_relationship_worker_spec.rb
502
+ - spec/workers/pull_mdm_id_worker_spec.rb
503
+ - spec/workers/delete_gr_entity_worker_spec.rb
504
+ - spec/helpers/sidekiq_helpers.rb