global-registry-bindings 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/lib/global_registry_bindings/entity/push_relationship_methods.rb +53 -29
- data/lib/global_registry_bindings/entity/relationship_type_methods.rb +17 -8
- data/lib/global_registry_bindings/global_registry_bindings.rb +21 -14
- data/lib/global_registry_bindings/model/entity.rb +13 -9
- data/lib/global_registry_bindings/model/push_relationship.rb +6 -0
- data/lib/global_registry_bindings/model/relationship.rb +12 -10
- data/lib/global_registry_bindings/options/entity_class_options.rb +4 -0
- data/lib/global_registry_bindings/options/entity_instance_options.rb +1 -0
- data/lib/global_registry_bindings/options/entity_options_parser.rb +1 -0
- data/lib/global_registry_bindings/options/relationship_class_options.rb +9 -0
- data/lib/global_registry_bindings/options/relationship_instance_options.rb +16 -6
- data/lib/global_registry_bindings/options/relationship_options_parser.rb +5 -5
- data/lib/global_registry_bindings/version.rb +1 -1
- data/lib/global_registry_bindings/workers/push_relationship_worker.rb +2 -2
- data/spec/acceptance/global_registry_bindings_spec.rb +11 -9
- data/spec/factories/factories.rb +2 -0
- data/spec/fixtures/get_entity_types_fancy_org_assignment.json +35 -0
- data/spec/fixtures/post_relationship_types_assigned_by.json +16 -0
- data/spec/fixtures/put_entities_fancy_org_assignment_assigned_by.json +20 -0
- data/spec/internal/app/models/area.rb +2 -1
- data/spec/internal/app/models/assignment.rb +12 -2
- data/spec/internal/app/models/community.rb +2 -1
- data/spec/internal/app/models/namespaced/person.rb +6 -2
- data/spec/internal/app/models/organization.rb +3 -1
- data/spec/internal/db/schema.rb +2 -0
- data/spec/internal/log/test.log +28818 -0
- data/spec/workers/push_relationship_worker_spec.rb +133 -33
- metadata +10 -4
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"entity": {
|
3
|
+
"fancy_org_assignment": {
|
4
|
+
"id": "51a014a4-4252-11e7-944f-129bd0521531",
|
5
|
+
"person:relationship": {
|
6
|
+
"person": "22527d88-3cba-11e7-b876-129bd0521531",
|
7
|
+
"relationship_entity_id": "0fd8b8b8-76c9-11e7-b15c-129bd0521531",
|
8
|
+
"client_integration_id": "1"
|
9
|
+
},
|
10
|
+
"person": {
|
11
|
+
"id": "22527d88-3cba-11e7-b876-129bd0521531"
|
12
|
+
},
|
13
|
+
"fancy_org": {
|
14
|
+
"id": "aebb4170-3f34-11e7-bba6-129bd0521531"
|
15
|
+
},
|
16
|
+
"client_integration_id": "1"
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"meta": {}
|
20
|
+
}
|
@@ -3,9 +3,19 @@
|
|
3
3
|
class Assignment < ApplicationRecord
|
4
4
|
belongs_to :person, class_name: 'Namespaced::Person'
|
5
5
|
belongs_to :organization
|
6
|
+
belongs_to :assigned_by, class_name: 'Namespaced::Person', foreign_key: 'assigned_by_id'
|
6
7
|
|
7
8
|
global_registry_bindings binding: :relationship,
|
8
|
-
type: :
|
9
|
+
type: :fancy_org_assignment,
|
9
10
|
primary_association: :person,
|
10
|
-
related_association: :organization
|
11
|
+
related_association: :organization,
|
12
|
+
exclude_fields: %i[assigned_by_id assigned_by_gr_rel_id]
|
13
|
+
|
14
|
+
global_registry_bindings binding: :relationship,
|
15
|
+
type: :assigned_by,
|
16
|
+
id_column: :assigned_by_gr_rel_id,
|
17
|
+
include_all_columns: false,
|
18
|
+
primary_binding: :fancy_org_assignment,
|
19
|
+
primary_relationship_name: :assigned_by,
|
20
|
+
related_association: :assigned_by
|
11
21
|
end
|
@@ -10,7 +10,8 @@ class Community < ApplicationRecord
|
|
10
10
|
related_relationship_name: :ministry,
|
11
11
|
related_association_type: :ministry,
|
12
12
|
related_association_foreign_key: :infobase_id,
|
13
|
-
related_global_registry_id: :pull_infobase_global_registry_id
|
13
|
+
related_global_registry_id: :pull_infobase_global_registry_id,
|
14
|
+
include_all_columns: false
|
14
15
|
|
15
16
|
def pull_infobase_global_registry_id(_type)
|
16
17
|
'41f767fd-86f4-42e2-8d24-cbc3f697b794'
|
@@ -27,14 +27,18 @@ module Namespaced
|
|
27
27
|
related_association: :country_of_service,
|
28
28
|
exclude_fields: :exclude_cos_fields,
|
29
29
|
extra_fields: :extra_cos_fields,
|
30
|
-
ensure_relationship_type: false
|
30
|
+
ensure_relationship_type: false,
|
31
|
+
rename_entity_type: false,
|
32
|
+
include_all_columns: false
|
31
33
|
|
32
34
|
global_registry_bindings binding: :relationship,
|
33
35
|
type: :country_of_residence,
|
34
36
|
id_column: :country_of_residence_gr_id,
|
35
37
|
client_integration_id: ->(model) { "cor_#{model.id}" },
|
36
38
|
related_association: :country_of_residence,
|
37
|
-
ensure_relationship_type: false
|
39
|
+
ensure_relationship_type: false,
|
40
|
+
rename_entity_type: false,
|
41
|
+
include_all_columns: false
|
38
42
|
|
39
43
|
def entity_attributes_to_push
|
40
44
|
entity_attributes = super
|
@@ -21,7 +21,9 @@ class Organization < ApplicationRecord
|
|
21
21
|
id_column: :global_registry_area_id,
|
22
22
|
related_association: :area,
|
23
23
|
exclude_fields: proc { |_type, _model| %i[] },
|
24
|
-
extra_fields: proc { |_type, _model| { priority: :string } }
|
24
|
+
extra_fields: proc { |_type, _model| { priority: :string } },
|
25
|
+
rename_entity_type: false,
|
26
|
+
include_all_columns: false
|
25
27
|
|
26
28
|
def exclude_gr_fields(_type)
|
27
29
|
%i[id created_at updated_at gr_id parent_id area_id global_registry_area_id]
|
data/spec/internal/db/schema.rb
CHANGED
@@ -38,10 +38,12 @@ ActiveRecord::Schema.define(version: 0) do
|
|
38
38
|
|
39
39
|
create_table :assignments, force: true do |t|
|
40
40
|
t.string :global_registry_id
|
41
|
+
t.string :assigned_by_gr_rel_id
|
41
42
|
t.string :role
|
42
43
|
t.datetime :hired_at
|
43
44
|
t.references :person, index: true
|
44
45
|
t.references :organization, index: true
|
46
|
+
t.references :assigned_by, index: true
|
45
47
|
t.timestamps
|
46
48
|
end
|
47
49
|
|