maestrano-connector-rails 0.2.15 → 0.2.16
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/controllers/maestrano/connec_controller.rb +2 -2
- data/app/jobs/maestrano/connector/rails/push_to_connec_job.rb +2 -2
- data/app/jobs/maestrano/connector/rails/synchronization_job.rb +1 -1
- data/app/models/maestrano/connector/rails/concerns/entity.rb +23 -11
- data/maestrano-connector-rails.gemspec +3 -3
- data/spec/controllers/connec_controller_spec.rb +3 -3
- data/spec/jobs/push_to_connec_job_spec.rb +3 -3
- data/spec/models/entity_spec.rb +74 -36
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac017da954066c7397861d757d620250c1f9d17
|
4
|
+
data.tar.gz: 95034e887a9a9e1ea69c66e397bcc1c9c698e824
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f47439af3beb4b4795d47ba4b5a9685ec35557d9aff988f90486d5ed313499752b46b55c2a7e469e93c34ecb6dd200efc2e570ed6d1aca30d395118a6e97aea
|
7
|
+
data.tar.gz: 9c91c0d18bb5edde590ce3a63349ac3fcd00fde0f359c30a8bd93d07372316c8998de736fa63a05b78250b1812553d554a12c8ea0c4e81277ef56bd49289402e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.16
|
@@ -16,7 +16,7 @@ class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
|
16
16
|
|
17
17
|
# Build expected input for consolidate_and_map_data
|
18
18
|
if entity_instance_hash[:is_complex]
|
19
|
-
mapped_entity = entity_instance.consolidate_and_map_data(Hash[ *entity_instance.connec_entities_names.collect{|name| name == entity_name
|
19
|
+
mapped_entity = entity_instance.consolidate_and_map_data(Hash[ *entity_instance.connec_entities_names.collect{|name| name.downcase.pluralize == entity_name ? [name, [entity]] : [ name, []]}.flatten(1) ], Hash[ *entity_instance.external_entities_names.collect{|name| [ name, []]}.flatten(1) ], organization, {})
|
20
20
|
else
|
21
21
|
mapped_entity = entity_instance.consolidate_and_map_data([entity], [], organization, {})
|
22
22
|
end
|
@@ -48,7 +48,7 @@ class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
|
48
48
|
if instance.methods.include?('connec_entities_names'.to_sym)
|
49
49
|
return {instance: instance, is_complex: true, name: entity_name_from_list} if instance.connec_entities_names.map{|n| n.pluralize.downcase}.include?(entity_name)
|
50
50
|
elsif instance.methods.include?('connec_entity_name'.to_sym)
|
51
|
-
return {instance: instance, is_complex: false, name: entity_name_from_list} if instance.
|
51
|
+
return {instance: instance, is_complex: false, name: entity_name_from_list} if instance.normalized_connec_entity_name == entity_name
|
52
52
|
end
|
53
53
|
end
|
54
54
|
nil
|
@@ -6,7 +6,7 @@ module Maestrano::Connector::Rails
|
|
6
6
|
def perform(organization, entities_hash)
|
7
7
|
return unless organization.sync_enabled && organization.oauth_uid
|
8
8
|
|
9
|
-
connec_client = Maestrano::Connec::Client.new(organization.uid)
|
9
|
+
connec_client = Maestrano::Connec::Client[organization.tenant].new(organization.uid)
|
10
10
|
|
11
11
|
entities_hash.each do |external_entity_name, entities|
|
12
12
|
if entity_instance_hash = find_entity_instance(external_entity_name)
|
@@ -14,7 +14,7 @@ module Maestrano::Connector::Rails
|
|
14
14
|
next unless organization.synchronized_entities[entity_instance_hash[:name].to_sym]
|
15
15
|
|
16
16
|
if entity_instance_hash[:is_complex]
|
17
|
-
mapped_entities = entity_instance.consolidate_and_map_data(Hash[ *entity_instance.connec_entities_names.collect{|name| [ name, []]}.flatten(1) ], Hash[ *entity_instance.external_entities_names.collect{|name| name == external_entity_name
|
17
|
+
mapped_entities = entity_instance.consolidate_and_map_data(Hash[ *entity_instance.connec_entities_names.collect{|name| [ name, []]}.flatten(1) ], Hash[ *entity_instance.external_entities_names.collect{|name| name == external_entity_name ? [name, entities] : [ name, []]}.flatten(1) ], organization, {})
|
18
18
|
else
|
19
19
|
mapped_entities = entity_instance.consolidate_and_map_data([], entities, organization, {})
|
20
20
|
end
|
@@ -22,7 +22,7 @@ module Maestrano::Connector::Rails
|
|
22
22
|
|
23
23
|
begin
|
24
24
|
last_synchronization = Synchronization.where(organization_id: organization.id, status: 'SUCCESS', partial: false).order(updated_at: :desc).first
|
25
|
-
connec_client = Maestrano::Connec::Client.new(organization.uid)
|
25
|
+
connec_client = Maestrano::Connec::Client[organization.tenant].new(organization.uid)
|
26
26
|
external_client = External.get_client(organization)
|
27
27
|
|
28
28
|
if opts[:only_entities]
|
@@ -28,6 +28,14 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
28
28
|
# ----------------------------------------------
|
29
29
|
# Connec! methods
|
30
30
|
# ----------------------------------------------
|
31
|
+
def normalized_connec_entity_name
|
32
|
+
if self.singleton?
|
33
|
+
self.connec_entity_name.downcase
|
34
|
+
else
|
35
|
+
self.connec_entity_name.downcase.pluralize
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
31
39
|
def get_connec_entities(client, last_synchronization, organization, opts={})
|
32
40
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Fetching Connec! #{self.connec_entity_name}")
|
33
41
|
|
@@ -36,18 +44,18 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
36
44
|
# Fetch first page
|
37
45
|
if last_synchronization.blank? || opts[:full_sync]
|
38
46
|
Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "entity=#{self.connec_entity_name}, fetching all data")
|
39
|
-
response = client.get("/#{self.
|
47
|
+
response = client.get("/#{self.normalized_connec_entity_name}")
|
40
48
|
else
|
41
49
|
Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "entity=#{self.connec_entity_name}, fetching data since #{last_synchronization.updated_at.iso8601}")
|
42
50
|
query_param = URI.encode("$filter=updated_at gt '#{last_synchronization.updated_at.iso8601}'")
|
43
|
-
response = client.get("/#{self.
|
51
|
+
response = client.get("/#{self.normalized_connec_entity_name}?#{query_param}")
|
44
52
|
end
|
45
53
|
raise "No data received from Connec! when trying to fetch #{self.connec_entity_name.pluralize}" unless response
|
46
54
|
|
47
55
|
response_hash = JSON.parse(response.body)
|
48
56
|
Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "received first page entity=#{self.connec_entity_name}, response=#{response.body}")
|
49
|
-
if response_hash["#{self.
|
50
|
-
entities << response_hash["#{self.
|
57
|
+
if response_hash["#{self.normalized_connec_entity_name}"]
|
58
|
+
entities << response_hash["#{self.normalized_connec_entity_name}"]
|
51
59
|
else
|
52
60
|
raise "Received unrecognized Connec! data when trying to fetch #{self.connec_entity_name.pluralize}"
|
53
61
|
end
|
@@ -55,15 +63,15 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
55
63
|
# Fetch subsequent pages
|
56
64
|
while response_hash['pagination'] && response_hash['pagination']['next']
|
57
65
|
# ugly way to convert https://api-connec/api/v2/group_id/organizations?next_page_params to /organizations?next_page_params
|
58
|
-
next_page = response_hash['pagination']['next'].gsub(/^(.*)\/#{self.
|
66
|
+
next_page = response_hash['pagination']['next'].gsub(/^(.*)\/#{self.normalized_connec_entity_name}/, self.normalized_connec_entity_name)
|
59
67
|
response = client.get(next_page)
|
60
68
|
|
61
69
|
raise "No data received from Connec! when trying to fetch subsequent page of #{self.connec_entity_name.pluralize}" unless response
|
62
70
|
Maestrano::Connector::Rails::ConnectorLogger.log('debug', organization, "received next page entity=#{self.connec_entity_name}, response=#{response.body}")
|
63
71
|
|
64
72
|
response_hash = JSON.parse(response.body)
|
65
|
-
if response_hash["#{self.
|
66
|
-
entities << response_hash["#{self.
|
73
|
+
if response_hash["#{self.normalized_connec_entity_name}"]
|
74
|
+
entities << response_hash["#{self.normalized_connec_entity_name}"]
|
67
75
|
else
|
68
76
|
raise "Received unrecognized Connec! data when trying to fetch subsequent page of #{self.connec_entity_name.pluralize}"
|
69
77
|
end
|
@@ -99,16 +107,16 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
99
107
|
|
100
108
|
def create_connec_entity(connec_client, mapped_external_entity, connec_entity_name, organization)
|
101
109
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending create #{connec_entity_name}: #{mapped_external_entity} to Connec!")
|
102
|
-
response = connec_client.post("/#{
|
110
|
+
response = connec_client.post("/#{normalized_connec_entity_name}", { "#{normalized_connec_entity_name}".to_sym => mapped_external_entity })
|
103
111
|
raise "No response received from Connec! when trying to create a #{self.connec_entity_name}" unless response
|
104
|
-
JSON.parse(response.body)["#{
|
112
|
+
JSON.parse(response.body)["#{normalized_connec_entity_name}"]
|
105
113
|
end
|
106
114
|
|
107
115
|
def update_connec_entity(connec_client, mapped_external_entity, connec_id, connec_entity_name, organization)
|
108
116
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Sending update #{connec_entity_name}: #{mapped_external_entity} to Connec!")
|
109
|
-
response = connec_client.put("/#{
|
117
|
+
response = connec_client.put("/#{normalized_connec_entity_name}/#{connec_id}", { "#{normalized_connec_entity_name}".to_sym => mapped_external_entity })
|
110
118
|
raise "No response received from Connec! when trying to update a #{self.connec_entity_name}" unless response
|
111
|
-
JSON.parse(response.body)["#{
|
119
|
+
JSON.parse(response.body)["#{normalized_connec_entity_name}"]
|
112
120
|
end
|
113
121
|
|
114
122
|
def map_to_external_with_idmap(entity, organization)
|
@@ -238,6 +246,10 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
238
246
|
# Entity specific methods
|
239
247
|
# Those methods need to be define in each entity
|
240
248
|
# ----------------------------------------------
|
249
|
+
# Is this resource a singleton (in Connec!)?
|
250
|
+
def singleton?
|
251
|
+
false
|
252
|
+
end
|
241
253
|
|
242
254
|
# Entity name in Connec!
|
243
255
|
def connec_entity_name
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: maestrano-connector-rails 0.2.
|
5
|
+
# stub: maestrano-connector-rails 0.2.16 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.16"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Pierre Berard"]
|
14
|
-
s.date = "2016-03-
|
14
|
+
s.date = "2016-03-07"
|
15
15
|
s.description = "Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details."
|
16
16
|
s.email = "pierre.berard@maestrano.com"
|
17
17
|
s.executables = ["rails"]
|
@@ -50,7 +50,7 @@ describe Maestrano::ConnecController, type: :controller do
|
|
50
50
|
allow(Maestrano::Connector::Rails::Entity).to receive(:entities_list).and_return(%w(contact_and_lead))
|
51
51
|
class Entities::ContactAndLead < Maestrano::Connector::Rails::ComplexEntity
|
52
52
|
def connec_entities_names
|
53
|
-
%w(
|
53
|
+
%w(Lead)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
module Entities::SubEntities end;
|
@@ -70,7 +70,7 @@ describe Maestrano::ConnecController, type: :controller do
|
|
70
70
|
let!(:organization) { create(:organization, uid: group_id, oauth_uid: 'lala', sync_enabled: true, synchronized_entities: {contact_and_lead: true}) }
|
71
71
|
|
72
72
|
it 'process the data and push them' do
|
73
|
-
expect_any_instance_of(Entities::ContactAndLead).to receive(:consolidate_and_map_data).with({"
|
73
|
+
expect_any_instance_of(Entities::ContactAndLead).to receive(:consolidate_and_map_data).with({"Lead"=>[entity]}, {}, organization, {}).and_return({})
|
74
74
|
expect_any_instance_of(Entities::ContactAndLead).to receive(:push_entities_to_external)
|
75
75
|
subject
|
76
76
|
end
|
@@ -84,7 +84,7 @@ describe Maestrano::ConnecController, type: :controller do
|
|
84
84
|
allow(Maestrano::Connector::Rails::Entity).to receive(:entities_list).and_return(%w(person))
|
85
85
|
class Entities::Person < Maestrano::Connector::Rails::Entity
|
86
86
|
def connec_entity_name
|
87
|
-
'
|
87
|
+
'People'
|
88
88
|
end
|
89
89
|
end
|
90
90
|
}
|
@@ -17,7 +17,7 @@ describe Maestrano::Connector::Rails::PushToConnecJob do
|
|
17
17
|
allow_any_instance_of(Entities::Entity2).to receive(:consolidate_and_map_data).and_return({})
|
18
18
|
allow_any_instance_of(Entities::Entity2).to receive(:push_entities_to_connec)
|
19
19
|
allow_any_instance_of(Entities::Entity2).to receive(:connec_entities_names).and_return(%w())
|
20
|
-
allow_any_instance_of(Entities::Entity2).to receive(:external_entities_names).and_return(%w(
|
20
|
+
allow_any_instance_of(Entities::Entity2).to receive(:external_entities_names).and_return(%w(Subs ll))
|
21
21
|
module Entities::SubEntities end;
|
22
22
|
class Entities::SubEntities::Sub < Maestrano::Connector::Rails::SubEntityBase
|
23
23
|
end
|
@@ -27,7 +27,7 @@ describe Maestrano::Connector::Rails::PushToConnecJob do
|
|
27
27
|
let(:entity11) { {first_name: 'John'} }
|
28
28
|
let(:entity12) { {first_name: 'Jane'} }
|
29
29
|
let(:entity21) { {job: 'Pizza guy'} }
|
30
|
-
let(:hash) { {'ext_entity1' => [entity11, entity12], '
|
30
|
+
let(:hash) { {'ext_entity1' => [entity11, entity12], 'Subs' => [entity21]} }
|
31
31
|
subject { Maestrano::Connector::Rails::PushToConnecJob.perform_now(organization, hash) }
|
32
32
|
|
33
33
|
describe 'with organization sync enabled set to false' do
|
@@ -66,7 +66,7 @@ describe Maestrano::Connector::Rails::PushToConnecJob do
|
|
66
66
|
before { organization.update(synchronized_entities: {:"#{entity_name1}" => false, :"#{entity_name2}" => true})}
|
67
67
|
|
68
68
|
it 'calls consolidate and map data on the complex entity with the right arguments' do
|
69
|
-
expect_any_instance_of(Entities::Entity2).to receive(:consolidate_and_map_data).with({}, {"
|
69
|
+
expect_any_instance_of(Entities::Entity2).to receive(:consolidate_and_map_data).with({}, {"Subs"=>[entity21], "ll"=>[]}, organization, {})
|
70
70
|
expect_any_instance_of(Entities::Entity2).to receive(:push_entities_to_connec)
|
71
71
|
subject
|
72
72
|
end
|
data/spec/models/entity_spec.rb
CHANGED
@@ -43,59 +43,91 @@ describe Maestrano::Connector::Rails::Entity do
|
|
43
43
|
describe 'connec_methods' do
|
44
44
|
let(:organization) { create(:organization) }
|
45
45
|
let(:client) { Maestrano::Connec::Client.new(organization.uid) }
|
46
|
-
let(:connec_name) { '
|
46
|
+
let(:connec_name) { 'Person' }
|
47
47
|
let(:external_name) { 'external_name' }
|
48
48
|
let(:sync) { create(:synchronization) }
|
49
49
|
before {
|
50
50
|
allow(subject).to receive(:connec_entity_name).and_return(connec_name)
|
51
51
|
}
|
52
52
|
|
53
|
-
describe '
|
53
|
+
describe 'normalized_connec_entity_name' do
|
54
|
+
context 'for a singleton resource' do
|
55
|
+
before {
|
56
|
+
allow(subject).to receive(:singleton?).and_return(true)
|
57
|
+
}
|
54
58
|
|
55
|
-
|
59
|
+
it { expect(subject.normalized_connec_entity_name).to eql('person') }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'for a non singleton resource' do
|
56
63
|
before {
|
57
|
-
allow(
|
64
|
+
allow(subject).to receive(:singleton?).and_return(false)
|
58
65
|
}
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
subject.get_connec_entities(client, nil, organization, {full_sync: true})
|
64
|
-
end
|
65
|
-
end
|
67
|
+
it { expect(subject.normalized_connec_entity_name).to eql('people') }
|
68
|
+
end
|
69
|
+
end
|
66
70
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
describe 'get_connec_entities' do
|
72
|
+
|
73
|
+
describe 'with response' do
|
74
|
+
context 'for a singleton resource' do
|
75
|
+
before {
|
76
|
+
allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {person: []}.to_json, {}))
|
77
|
+
allow(subject).to receive(:singleton?).and_return(true)
|
78
|
+
}
|
73
79
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
expect(client).to receive(:get).with("/#{connec_name.downcase.pluralize}?#{uri_param}")
|
78
|
-
subject.get_connec_entities(client, sync, organization)
|
80
|
+
it 'calls get with a singularize url' do
|
81
|
+
expect(client).to receive(:get).with("/#{connec_name.downcase}")
|
82
|
+
subject.get_connec_entities(client, nil, organization)
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
82
|
-
context '
|
86
|
+
context 'for a non singleton resource' do
|
83
87
|
before {
|
84
|
-
allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {people: []
|
88
|
+
allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {people: []}.to_json, {}))
|
85
89
|
}
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
91
|
+
context 'when opts[:full_sync] is true' do
|
92
|
+
it 'performs a full get' do
|
93
|
+
expect(client).to receive(:get).with("/#{connec_name.downcase.pluralize}")
|
94
|
+
subject.get_connec_entities(client, nil, organization, {full_sync: true})
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when there is no last sync' do
|
99
|
+
it 'performs a full get' do
|
100
|
+
expect(client).to receive(:get).with("/#{connec_name.downcase.pluralize}")
|
101
|
+
subject.get_connec_entities(client, nil, organization)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when there is a last sync' do
|
106
|
+
it 'performs a time limited get' do
|
107
|
+
uri_param = URI.encode("$filter=updated_at gt '#{sync.updated_at.iso8601}'")
|
108
|
+
expect(client).to receive(:get).with("/#{connec_name.downcase.pluralize}?#{uri_param}")
|
109
|
+
subject.get_connec_entities(client, sync, organization)
|
110
|
+
end
|
90
111
|
end
|
91
|
-
end
|
92
112
|
|
93
|
-
|
94
|
-
|
113
|
+
context 'with pagination' do
|
114
|
+
before {
|
115
|
+
allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {people: [], pagination: {next: "https://api-connec.maestrano.com/api/v2/cld-dkg601/people?%24skip=10&%24top=10"}}.to_json, {}), ActionDispatch::Response.new(200, {}, {people: []}.to_json, {}))
|
116
|
+
}
|
95
117
|
|
96
|
-
|
97
|
-
|
98
|
-
|
118
|
+
it 'calls get multiple times' do
|
119
|
+
expect(client).to receive(:get).twice
|
120
|
+
subject.get_connec_entities(client, nil, organization)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'with an actual response' do
|
125
|
+
let(:people) { [{first_name: 'John'}, {last_name: 'Durand'}, {job_title: 'Engineer'}] }
|
126
|
+
|
127
|
+
it 'returns an array of entities' do
|
128
|
+
allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {people: people}.to_json, {}))
|
129
|
+
expect(subject.get_connec_entities(client, nil, organization)).to eql(JSON.parse(people.to_json))
|
130
|
+
end
|
99
131
|
end
|
100
132
|
end
|
101
133
|
end
|
@@ -141,7 +173,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
141
173
|
expect(idmap1.last_push_to_connec).to_not eql(old_push_date)
|
142
174
|
idmap2.reload
|
143
175
|
expect(idmap2.connec_id).to eql(id)
|
144
|
-
expect(idmap2.connec_entity).to eql(connec_name)
|
176
|
+
expect(idmap2.connec_entity).to eql(connec_name.downcase)
|
145
177
|
expect(idmap2.last_push_to_connec).to_not be_nil
|
146
178
|
end
|
147
179
|
end
|
@@ -155,7 +187,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
155
187
|
}
|
156
188
|
|
157
189
|
it 'sends a post to connec' do
|
158
|
-
expect(client).to receive(:post).with("/#{connec_name.pluralize}", {"#{connec_name.pluralize}".to_sym => entity})
|
190
|
+
expect(client).to receive(:post).with("/#{connec_name.downcase.pluralize}", {"#{connec_name.downcase.pluralize}".to_sym => entity})
|
159
191
|
subject.create_connec_entity(client, entity, connec_name, organization)
|
160
192
|
end
|
161
193
|
|
@@ -183,7 +215,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
183
215
|
}
|
184
216
|
|
185
217
|
it 'sends a put to connec' do
|
186
|
-
expect(client).to receive(:put).with("/#{connec_name.pluralize}/#{id}", {"#{connec_name.pluralize}".to_sym => entity})
|
218
|
+
expect(client).to receive(:put).with("/#{connec_name.downcase.pluralize}/#{id}", {"#{connec_name.downcase.pluralize}".to_sym => entity})
|
187
219
|
subject.update_connec_entity(client, entity, id, connec_name, organization)
|
188
220
|
end
|
189
221
|
end
|
@@ -206,7 +238,7 @@ describe Maestrano::Connector::Rails::Entity do
|
|
206
238
|
}
|
207
239
|
|
208
240
|
context 'when entity has an idmap' do
|
209
|
-
let!(:idmap) { create(:idmap, organization: organization, connec_entity: connec_name, connec_id: id, last_push_to_external: 3.hour.ago)}
|
241
|
+
let!(:idmap) { create(:idmap, organization: organization, connec_entity: connec_name.downcase, connec_id: id, last_push_to_external: 3.hour.ago)}
|
210
242
|
|
211
243
|
context 'when updated_at field is most recent than idmap last_push_to_external' do
|
212
244
|
let(:entity) { {'id' => id, 'name' => 'John', 'updated_at' => 2.hour.ago } }
|
@@ -459,6 +491,12 @@ describe Maestrano::Connector::Rails::Entity do
|
|
459
491
|
|
460
492
|
|
461
493
|
# Entity specific methods
|
494
|
+
describe 'singleton?' do
|
495
|
+
it 'is false by default' do
|
496
|
+
expect(subject.singleton?).to be false
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
462
500
|
describe 'connec_entity_name' do
|
463
501
|
it { expect{ subject.connec_entity_name }.to raise_error('Not implemented') }
|
464
502
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestrano-connector-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Berard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maestrano-rails
|