maestrano-connector-rails 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/models/maestrano/connector/rails/concerns/connec_helper.rb +2 -2
- data/app/models/maestrano/connector/rails/concerns/entity.rb +4 -4
- data/maestrano-connector-rails.gemspec +3 -3
- data/spec/models/connec_helper_spec.rb +11 -2
- data/spec/models/entity_spec.rb +2 -2
- 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: b6c98a08a281bfea7334aa9670a91b0e6f49a85e
|
4
|
+
data.tar.gz: 6800242ca6b7d834df0d4acd6128541f8adf7f4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78d4add0da696a67f179f24de422e65b9f84dc0eed4ef1108c89c17c917e089afd58acd2423b754eeb3342272136c6460d6f679229bb7f110b11c9e3809014b1
|
7
|
+
data.tar.gz: c2c008d2c6ce5387b0a527b359b23af8669ffc7b3b094fe7676c752318a950297178be80c4e3c7372ae25732d88e0b9f06fe2aded0d3a9328a739057fc345d3e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -51,7 +51,7 @@ module Maestrano::Connector::Rails::Concerns::ConnecHelper
|
|
51
51
|
ref = array_of_refs.shift
|
52
52
|
field = entity[ref]
|
53
53
|
|
54
|
-
# Follow embedment path, remplace if it's a
|
54
|
+
# Follow embedment path, remplace if it's not an array or a hash
|
55
55
|
unless field.blank?
|
56
56
|
case field
|
57
57
|
when Array
|
@@ -60,7 +60,7 @@ module Maestrano::Connector::Rails::Concerns::ConnecHelper
|
|
60
60
|
end
|
61
61
|
when HashWithIndifferentAccess
|
62
62
|
fold_references_helper(entity[ref], array_of_refs, organization)
|
63
|
-
|
63
|
+
else
|
64
64
|
id = field
|
65
65
|
entity[ref] = [id_hash(id, organization)]
|
66
66
|
end
|
@@ -244,7 +244,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
244
244
|
|
245
245
|
unless ids_to_send_to_connec.empty?
|
246
246
|
# Send the external ids to connec if it was a creation
|
247
|
-
proc = lambda{|id| batch_op('put', {id: [Maestrano::Connector::Rails::ConnecHelper.id_hash(id[:external_id
|
247
|
+
proc = lambda{|id| batch_op('put', {id: [Maestrano::Connector::Rails::ConnecHelper.id_hash(id[:idmap].external_id, @organization)]}, id[:idmap].connec_id, self.class.normalize_connec_entity_name(self.class.connec_entity_name)) }
|
248
248
|
batch_calls(ids_to_send_to_connec, proc, self.class.connec_entity_name, true)
|
249
249
|
end
|
250
250
|
end
|
@@ -257,10 +257,10 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
257
257
|
begin
|
258
258
|
# Create and return id to send to connec!
|
259
259
|
if idmap.external_id.blank?
|
260
|
-
connec_id =
|
260
|
+
connec_id = idmap.connec_id
|
261
261
|
external_id = create_external_entity(mapped_connec_entity, external_entity_name)
|
262
262
|
idmap.update(external_id: external_id, last_push_to_external: Time.now, message: nil)
|
263
|
-
return {
|
263
|
+
return {idmap: idmap}
|
264
264
|
|
265
265
|
# Update
|
266
266
|
else
|
@@ -271,7 +271,7 @@ module Maestrano::Connector::Rails::Concerns::Entity
|
|
271
271
|
if self.class.singleton? && idmap.last_push_to_external.nil?
|
272
272
|
connec_id = mapped_connec_entity_with_idmap[:idmap].connec_id
|
273
273
|
idmap.update(last_push_to_external: Time.now, message: nil)
|
274
|
-
return {
|
274
|
+
return {idmap: idmap}
|
275
275
|
else
|
276
276
|
idmap.update(last_push_to_external: Time.now, message: nil)
|
277
277
|
end
|
@@ -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 1.0.
|
5
|
+
# stub: maestrano-connector-rails 1.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.2"
|
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-05-
|
14
|
+
s.date = "2016-05-27"
|
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"]
|
@@ -94,9 +94,10 @@ describe Maestrano::Connector::Rails::ConnecHelper do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
describe 'fold_references' do
|
97
|
+
let(:id) { 'id1' }
|
97
98
|
let(:mapped_hash) {
|
98
99
|
{
|
99
|
-
id:
|
100
|
+
id: id,
|
100
101
|
organization_id: nil,
|
101
102
|
contact: {
|
102
103
|
id: ''
|
@@ -115,7 +116,7 @@ describe Maestrano::Connector::Rails::ConnecHelper do
|
|
115
116
|
let(:output_hash) {
|
116
117
|
{
|
117
118
|
"id" => [
|
118
|
-
subject.id_hash(
|
119
|
+
subject.id_hash(id, organization)
|
119
120
|
],
|
120
121
|
"organization_id" => nil,
|
121
122
|
"contact" => {
|
@@ -139,5 +140,13 @@ describe Maestrano::Connector::Rails::ConnecHelper do
|
|
139
140
|
it 'folds the existing refs' do
|
140
141
|
expect(subject.fold_references(mapped_hash, ['organization_id', 'contact/id', 'lines/id', 'not_here_ref'], organization)).to eql(output_hash.with_indifferent_access)
|
141
142
|
end
|
143
|
+
|
144
|
+
context 'when id is an integer' do
|
145
|
+
let(:id) { 1234 }
|
146
|
+
|
147
|
+
it 'folds the existing refs' do
|
148
|
+
expect(subject.fold_references(mapped_hash, ['organization_id', 'contact/id', 'lines/id', 'not_here_ref'], organization)).to eql(output_hash.with_indifferent_access)
|
149
|
+
end
|
150
|
+
end
|
142
151
|
end
|
143
152
|
end
|
data/spec/models/entity_spec.rb
CHANGED
@@ -574,9 +574,9 @@ describe Maestrano::Connector::Rails::Entity do
|
|
574
574
|
expect(idmap2.last_push_to_external).to_not be_nil
|
575
575
|
end
|
576
576
|
|
577
|
-
it 'returns an hash with the
|
577
|
+
it 'returns an hash with the idmap' do
|
578
578
|
allow(subject).to receive(:create_external_entity).and_return('999111')
|
579
|
-
expect(subject.push_entity_to_external(entity_with_idmap2, external_name)).to eql({
|
579
|
+
expect(subject.push_entity_to_external(entity_with_idmap2, external_name)).to eql({idmap: idmap2})
|
580
580
|
end
|
581
581
|
end
|
582
582
|
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
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-05-
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maestrano-rails
|