maestrano-connector-rails 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9444b9cdc7de73b532ce22743daf00eed51f6a88
4
- data.tar.gz: 68ae18a05cdca6bf985e6927c06d108ff0cc58bf
3
+ metadata.gz: f35f9299a109e93d0c7028759a390d44dd7bff6c
4
+ data.tar.gz: 0e4695072a4fa120a03195bd405f459ff37025f4
5
5
  SHA512:
6
- metadata.gz: 80667b16e9b8d3436992174980c206b91bf8c95b9e1e5169d8aa6f5e963e9543e08be773633b00a49c14f08f06f1032213f49f2db75b7d162d6293e4e5cf75dd
7
- data.tar.gz: ad3e5ff87948d0e537ab5d429a021e611f997f47eeca4bac250bdaeb4d33386bfed54d667ff9ceb9518ad0f081cba64e89803588d8b963fdfec393eaed84e133
6
+ metadata.gz: fd0dff595ef6a407c615d2aa25f3ceb63a74416fece30e9f7332c00c964f991989ffb184b69537f910a662f941b7919750d4c2f75b8fcfcc47f2f80c0bbf47d9
7
+ data.tar.gz: d656df9663e232ec8f6c805353cffe338961d79c200e31ed2526ce8d3c0e6298fb4f9698543c7d8ebd91c2412645410ece0e4560ca57d235e38ca3700679bb6e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -86,7 +86,7 @@ module Maestrano::Connector::Rails::Concerns::SubEntityBase
86
86
  if self.class.references[name]
87
87
  self.class.references[name].each do |ref|
88
88
  field = self.class.external? ? ref[:connec_field] : ref[:external_field]
89
- ref_hash.merge! field.split('/').reverse.inject(Maestrano::Connector::Rails::Entity.id_from_ref(entity, ref, false, organization)) { |a, n| { n.to_sym => a } }
89
+ ref_hash.merge! field.split('/').reverse.inject(Maestrano::Connector::Rails::Entity.id_from_ref(entity, ref, self.class.external?, organization)) { |a, n| { n.to_sym => a } }
90
90
  end
91
91
  end
92
92
 
@@ -11,13 +11,10 @@
11
11
  # 'contact'
12
12
  # end
13
13
 
14
- # def map_to(name, entity, organization)
15
- # case name
16
- # when 'person'
17
- # Entities::SubEntities::ContactMapper.denormalize(entity)
18
- # else
19
- # raise "Impossible mapping from #{self.class.entity_name} to #{name}"
20
- # end
14
+ # def self.mapper_classes
15
+ # {
16
+ # 'person' => Entities::SubEntities::ContactMapper
17
+ # }
21
18
  # end
22
19
 
23
20
  # def self.object_name_from_connec_entity_hash(entity)
@@ -11,13 +11,10 @@
11
11
  # 'lead'
12
12
  # end
13
13
 
14
- # def map_to(name, entity, organization)
15
- # case name
16
- # when 'person'
17
- # Entities::SubEntities::LeadMapper.denormalize(entity).merge(is_lead: true)
18
- # else
19
- # raise "Impossible mapping from #{self.class.entity_name} to #{name}"
20
- # end
14
+ # def self.mapper_classes
15
+ # {
16
+ # 'person' => Entities::SubEntities::LeadMapper
17
+ # }
21
18
  # end
22
19
 
23
20
  # def self.object_name_from_connec_entity_hash(entity)
@@ -4,6 +4,11 @@
4
4
  # class Entities::SubEntities::LeadMapper
5
5
  # extend HashMapper
6
6
 
7
+ # after_denormalize do |input, output|
8
+ # output[:is_lead] = true
9
+ # output
10
+ # end
11
+
7
12
  # map from('title'), to('Salutation')
8
13
  # map from('first_name'), to('FirstName')
9
14
  # map from('last_name'), to('LastName'), default: 'Undefined'
@@ -10,15 +10,11 @@
10
10
  # 'person'
11
11
  # end
12
12
 
13
- # def map_to(name, entity, organization)
14
- # case name
15
- # when 'lead'
16
- # Enities::SubEntities::LeadMapper.normalize(entity)
17
- # when 'contact'
18
- # Enities::SubEntities::ContactMapper.normalize(entity)
19
- # else
20
- # raise "Impossible mapping from #{self.class.entity_name} to #{name}"
21
- # end
13
+ # def self.mapper_classes
14
+ # {
15
+ # 'lead' => Entities::SubEntities::LeadMapper,
16
+ # 'contact' => Entities::SubEntities::ContactMapper,
17
+ # }
22
18
  # end
23
19
 
24
20
  # def self.object_name_from_connec_entity_hash(entity)
@@ -2,11 +2,11 @@
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.3.2 ruby lib
5
+ # stub: maestrano-connector-rails 0.3.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "maestrano-connector-rails"
9
- s.version = "0.3.2"
9
+ s.version = "0.3.3"
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"]
@@ -110,6 +110,8 @@ describe Maestrano::Connector::Rails::SubEntityBase do
110
110
  }
111
111
  end
112
112
  end
113
+
114
+ it { expect(subject.mapper_classes).to eql({}) }
113
115
  end
114
116
 
115
117
  describe 'instance methods' do
@@ -132,6 +134,20 @@ describe Maestrano::Connector::Rails::SubEntityBase do
132
134
  expect(AMapper).to receive(:denormalize).and_return({})
133
135
  subject.map_to('Name', {}, nil)
134
136
  end
137
+
138
+ context 'with references' do
139
+ let!(:organization) { create(:organization) }
140
+ let!(:idmap) { create(:idmap, organization: organization) }
141
+ before {
142
+ clazz = Maestrano::Connector::Rails::Entity
143
+ allow(clazz).to receive(:find_idmap).and_return(idmap)
144
+ allow(subject.class).to receive(:references).and_return({'Name' => [{reference_class: clazz, connec_field: 'organization_id', external_field: 'contact_id'}]})
145
+ }
146
+
147
+ it 'returns the mapped entity with its references' do
148
+ expect(subject.map_to('Name', {'contact_id' => idmap.external_id}, organization)).to eql({organization_id: idmap.connec_id})
149
+ end
150
+ end
135
151
  end
136
152
  context 'when not external' do
137
153
  before {
@@ -142,6 +158,20 @@ describe Maestrano::Connector::Rails::SubEntityBase do
142
158
  expect(AMapper).to receive(:normalize).and_return({})
143
159
  subject.map_to('Name', {}, nil)
144
160
  end
161
+
162
+ context 'with references' do
163
+ let!(:organization) { create(:organization) }
164
+ let!(:idmap) { create(:idmap, organization: organization) }
165
+ before {
166
+ clazz = Maestrano::Connector::Rails::Entity
167
+ allow(clazz).to receive(:find_idmap).and_return(idmap)
168
+ allow(subject.class).to receive(:references).and_return({'Name' => [{reference_class: clazz, connec_field: 'organization_id', external_field: 'contact_id'}]})
169
+ }
170
+
171
+ it 'returns the mapped entity with its references' do
172
+ expect(subject.map_to('Name', {'organization_id' => idmap.connec_id}, organization)).to eql({contact_id: idmap.external_id})
173
+ end
174
+ end
145
175
  end
146
176
  end
147
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano-connector-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Berard