global-registry-bindings 0.6.2 → 0.6.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.
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 +10 -8
  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,33 +0,0 @@
1
- {
2
- "relationship_type": {
3
- "id": "5d721db8-4248-11e7-90b4-129bd0521531",
4
- "relationship_entity_type_id": "5d70b630-4248-11e7-90b4-129bd0521531",
5
- "relationship1": {
6
- "entity_type": "person",
7
- "relationship_name": "person"
8
- },
9
- "relationship2": {
10
- "entity_type": "fancy_org",
11
- "relationship_name": "fancy_org"
12
- },
13
- "fields": [
14
- {
15
- "id": "235ce6fc-4249-11e7-944f-129bd0521531",
16
- "name": "role",
17
- "data_visibility": "public",
18
- "field_type": "string",
19
- "is_editable": true,
20
- "unique_value": false
21
- },
22
- {
23
- "id": "675bd9ee-4249-11e7-9e93-129bd0521531",
24
- "name": "hired_on",
25
- "data_visibility": "public",
26
- "field_type": "datetime",
27
- "is_editable": true,
28
- "unique_value": false
29
- }
30
- ],
31
- "is_editable": true
32
- }
33
- }
@@ -1,25 +0,0 @@
1
- {
2
- "relationship_type": {
3
- "id": "f03b947e-6644-11e7-93dd-129bd0521531",
4
- "relationship_entity_type_id": "f03a929a-6644-11e7-93dd-129bd0521531",
5
- "relationship1": {
6
- "entity_type": "fancy_org",
7
- "relationship_name": "fancy_org"
8
- },
9
- "relationship2": {
10
- "entity_type": "area",
11
- "relationship_name": "area"
12
- },
13
- "fields": [
14
- {
15
- "id": "ac0bde52-6645-11e7-80e8-129bd0521531",
16
- "name": "priority",
17
- "data_visibility": "public",
18
- "field_type": "string",
19
- "is_editable": true,
20
- "unique_value": false
21
- }
22
- ],
23
- "is_editable": true
24
- }
25
- }
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SidekiqHelpers
4
- def clear_sidekiq_jobs_and_locks
5
- # Drop sidekiq-unique-jobs locks
6
- MOCK_REDIS.keys.each do |key|
7
- MOCK_REDIS.del(key)
8
- end
9
-
10
- # Clear sidekiq queues and workers
11
- Sidekiq::Queues.clear_all
12
- Sidekiq::Worker.clear_all
13
- end
14
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Address < ApplicationRecord
4
- EXCLUDE_GR_FIELDS = %i[id created_at updated_at global_registry_id person_id address1].freeze
5
- belongs_to :person, class_name: 'Namespaced::Person', inverse_of: :addresses
6
- global_registry_bindings parent: :person,
7
- exclude: proc { |_type, _model| EXCLUDE_GR_FIELDS },
8
- fields: :global_registry_extra_fields,
9
- include_all_columns: true
10
-
11
- alias_attribute :line1, :address1
12
- alias_attribute :postal_code, :zip
13
-
14
- def global_registry_extra_fields(_type)
15
- { line1: :string, line2: :string, postal_code: :string }
16
- end
17
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationRecord < ActiveRecord::Base
4
- self.abstract_class = true
5
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Area < ApplicationRecord
4
- has_many :organizations
5
-
6
- global_registry_bindings fields: { area_name: :string, area_code: :string, is_active: :boolean }
7
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Assignment < ApplicationRecord
4
- belongs_to :person, class_name: 'Namespaced::Person'
5
- belongs_to :organization
6
- belongs_to :assigned_by, class_name: 'Namespaced::Person', foreign_key: 'assigned_by_id'
7
-
8
- global_registry_bindings binding: :relationship,
9
- type: :fancy_org_assignment,
10
- primary: :person,
11
- related: :organization,
12
- include_all_columns: true,
13
- exclude: %i[assigned_by_id assigned_by_gr_rel_id]
14
-
15
- global_registry_bindings binding: :relationship,
16
- type: :assigned_by,
17
- id_column: :assigned_by_gr_rel_id,
18
- primary_binding: :fancy_org_assignment,
19
- primary_name: :assigned_by,
20
- related: :assigned_by
21
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Community < ApplicationRecord
4
- global_registry_bindings ensure_type: false,
5
- include_all_columns: true,
6
- exclude: %i[infobase_id infobase_gr_id]
7
-
8
- global_registry_bindings binding: :relationship,
9
- type: :infobase_ministry,
10
- id_column: :infobase_gr_id,
11
- related_binding: :remote,
12
- related_name: :ministry,
13
- related_type: :ministry,
14
- related_foreign_key: :infobase_id,
15
- related_global_registry_id: :pull_infobase_global_registry_id
16
-
17
- def pull_infobase_global_registry_id(_type)
18
- '41f767fd-86f4-42e2-8d24-cbc3f697b794'
19
- end
20
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Country < ApplicationRecord
4
- has_many :employees, class_name: 'Namespaced::Person', inverse_of: :country_of_service
5
- has_many :residents, class_name: 'Namespaced::Person', inverse_of: :country_of_residence
6
-
7
- global_registry_bindings ensure_type: false, include_all_columns: true
8
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Default < ApplicationRecord
4
- self.table_name = :people
5
- global_registry_bindings
6
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Namespaced
4
- class Person
5
- class UserEdited < Namespaced::Person
6
- end
7
- end
8
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Namespaced
4
- class Person < ApplicationRecord
5
- has_many :addresses, dependent: :destroy, inverse_of: :person
6
- has_many :assignments
7
- has_many :organizations, through: :assignments
8
- belongs_to :country_of_service,
9
- class_name: 'Country',
10
- foreign_key: :country_of_service_id,
11
- inverse_of: :employees
12
- belongs_to :country_of_residence,
13
- class_name: 'Country',
14
- foreign_key: :country_of_residence_id,
15
- inverse_of: :residents
16
-
17
- global_registry_bindings binding: :entity,
18
- mdm_id_column: :global_registry_mdm_id,
19
- mdm_timeout: 24.hours,
20
- fingerprint_column: :global_registry_fingerprint,
21
- include_all_columns: true,
22
- exclude: %i[guid country_of_service_gr_id country_of_service_id
23
- country_of_residence_gr_id country_of_residence_id]
24
-
25
- global_registry_bindings binding: :relationship,
26
- type: :country_of_service,
27
- id_column: :country_of_service_gr_id,
28
- client_integration_id: ->(model) { "cos_#{model.id}" },
29
- related: :country_of_service,
30
- exclude: :exclude_cos_fields,
31
- fields: :extra_cos_fields,
32
- ensure_type: false,
33
- rename_entity_type: false
34
-
35
- global_registry_bindings binding: :relationship,
36
- type: :country_of_residence,
37
- id_column: :country_of_residence_gr_id,
38
- client_integration_id: ->(model) { "cor_#{model.id}" },
39
- related: :country_of_residence,
40
- ensure_type: false,
41
- rename_entity_type: false
42
-
43
- def entity_attributes_to_push
44
- entity_attributes = super
45
- entity_attributes[:authentication] = { key_guid: guid }
46
- entity_attributes
47
- end
48
-
49
- def exclude_cos_fields(_type)
50
- %i[]
51
- end
52
-
53
- def extra_cos_fields(_type)
54
- {}
55
- end
56
-
57
- def relationship_attributes_to_push(type)
58
- entity_attributes = super(type)
59
- case type
60
- when :country_of_service
61
- entity_attributes[:country_of_service] = true
62
- when :country_of_residence
63
- entity_attributes[:country_of_residence] = true
64
- end
65
- entity_attributes
66
- end
67
- end
68
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Organization < ApplicationRecord
4
- has_many :children, class_name: 'Organization', foreign_key: :parent_id
5
- belongs_to :parent, class_name: 'Organization'
6
-
7
- has_many :assignments
8
- has_many :people, class_name: 'Namespaced::Person', through: :assignments
9
-
10
- belongs_to :area
11
-
12
- global_registry_bindings id_column: :gr_id,
13
- type: ->(_model) { :fancy_org },
14
- push_on: %i[create destroy],
15
- parent: :parent,
16
- include_all_columns: true,
17
- exclude: :exclude_gr_fields,
18
- fields: proc { |_type, _model| {} }
19
-
20
- global_registry_bindings binding: :relationship,
21
- type: :area,
22
- id_column: :global_registry_area_id,
23
- related: :area,
24
- exclude: proc { |_type, _model| %i[] },
25
- fields: proc { |_type, _model| { priority: :string } },
26
- rename_entity_type: false
27
-
28
- def exclude_gr_fields(_type)
29
- %i[id created_at updated_at gr_id parent_id area_id global_registry_area_id]
30
- end
31
-
32
- def relationship_attributes_to_push(type)
33
- entity_attributes = super(type)
34
- entity_attributes[:priority] = 'High' if type == :area
35
- entity_attributes
36
- end
37
- end
@@ -1,4 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: db/test.sqlite
4
- timeout: 500
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'global_registry'
4
-
5
- GlobalRegistry.configure do |config|
6
- config.access_token = 'fake'
7
- config.base_url = 'https://backend.global-registry.org'
8
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.routes.draw do
4
- #
5
- end
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ActiveRecord::Schema.define(version: 0) do
4
- create_table :people, force: true do |t|
5
- t.string :global_registry_id
6
- t.string :global_registry_mdm_id
7
- t.string :global_registry_fingerprint
8
- t.string :first_name
9
- t.string :last_name
10
- t.string :guid
11
- t.references :country_of_service, index: true
12
- t.references :country_of_residence, index: true
13
- t.string :country_of_service_gr_id
14
- t.string :country_of_residence_gr_id
15
- t.timestamps
16
- end
17
-
18
- create_table :addresses, force: true do |t|
19
- t.string :global_registry_id
20
- t.string :address1
21
- t.string :zip
22
- t.boolean :primary
23
- t.references :person, index: true
24
- t.timestamps
25
- end
26
-
27
- create_table :organizations, force: true do |t|
28
- t.string :gr_id
29
- t.string :name
30
- t.text :description
31
- t.date :start_date
32
- t.references :parent, index: true
33
- t.references :area, index: true
34
- t.string :global_registry_area_id
35
- t.timestamps
36
- end
37
-
38
- create_table :assignments, force: true do |t|
39
- t.string :global_registry_id
40
- t.string :assigned_by_gr_rel_id
41
- t.string :role
42
- t.datetime :hired_at
43
- t.references :person, index: true
44
- t.references :organization, index: true
45
- t.references :assigned_by, index: true
46
- t.timestamps
47
- end
48
-
49
- create_table :areas, force: true do |t|
50
- t.string :global_registry_id
51
- t.string :area_name
52
- t.string :area_code
53
- t.boolean :is_active
54
- t.timestamps
55
- end
56
-
57
- create_table :countries, force: true do |t|
58
- t.string :name
59
- t.string :global_registry_id
60
- t.timestamps
61
- end
62
-
63
- create_table :communities, force: true do |t|
64
- t.string :name
65
- t.string :global_registry_id
66
- t.integer :infobase_id
67
- t.string :infobase_gr_id
68
- t.timestamps
69
- end
70
-
71
- create_table :foos, force: true do |t|
72
- t.string :global_registry_id
73
- t.timestamps
74
- end
75
- end
Binary file