maestrano-connector-rails 0.2.20 → 0.3.0

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.
@@ -8,35 +8,6 @@ describe Maestrano::Connector::Rails::Entity do
8
8
  describe 'entities_list' do
9
9
  it { expect(subject.entities_list).to eql(%w(entity1 entity2))}
10
10
  end
11
- end
12
-
13
- describe 'instance methods' do
14
- subject { Maestrano::Connector::Rails::Entity.new }
15
-
16
- describe 'Mapper methods' do
17
- before(:each) {
18
- class AMapper
19
- extend HashMapper
20
- def self.set_organization(organization_id)
21
- end
22
- end
23
- allow(subject).to receive(:mapper_class).and_return(AMapper)
24
- }
25
-
26
- describe 'map_to_external' do
27
- it 'calls the setter normalize' do
28
- expect(AMapper).to receive(:normalize).with({})
29
- subject.map_to_external({}, nil)
30
- end
31
- end
32
-
33
- describe 'map_to_connec' do
34
- it 'calls the setter denormalize' do
35
- expect(AMapper).to receive(:denormalize).with({})
36
- subject.map_to_connec({}, nil)
37
- end
38
- end
39
- end
40
11
 
41
12
  # IdMap methods
42
13
  describe 'idmaps mehtods' do
@@ -61,7 +32,7 @@ describe Maestrano::Connector::Rails::Entity do
61
32
  before {
62
33
  allow(subject).to receive(:object_name_from_external_entity_hash).and_return('name_e')
63
34
  allow(subject).to receive(:object_name_from_connec_entity_hash).and_return('name_c')
64
- allow(subject).to receive(:get_id_from_external_entity_hash).and_return('id')
35
+ allow(subject).to receive(:id_from_external_entity_hash).and_return('id')
65
36
  }
66
37
 
67
38
  it {
@@ -73,37 +44,118 @@ describe Maestrano::Connector::Rails::Entity do
73
44
  subject.create_idmap_from_external_entity({}, organization)
74
45
  }
75
46
  end
76
-
77
47
  end
78
48
 
79
- # Connec! methods
80
- describe 'connec_methods' do
81
- let(:organization) { create(:organization) }
82
- let(:client) { Maestrano::Connec::Client.new(organization.uid) }
83
- let(:connec_name) { 'Person' }
84
- let(:external_name) { 'external_name' }
85
- let(:sync) { create(:synchronization) }
49
+ describe 'normalized_connec_entity_name' do
86
50
  before {
87
51
  allow(subject).to receive(:connec_entity_name).and_return(connec_name)
88
52
  }
53
+ context 'for a singleton resource' do
54
+ before {
55
+ allow(subject).to receive(:singleton?).and_return(true)
56
+ }
89
57
 
90
- describe 'normalized_connec_entity_name' do
91
- context 'for a singleton resource' do
92
- before {
93
- allow(subject).to receive(:singleton?).and_return(true)
94
- }
95
-
58
+ context 'for a simple name' do
59
+ let(:connec_name) { 'Person' }
96
60
  it { expect(subject.normalized_connec_entity_name).to eql('person') }
97
61
  end
98
62
 
99
- context 'for a non singleton resource' do
100
- before {
101
- allow(subject).to receive(:singleton?).and_return(false)
102
- }
63
+ context 'for a complex name' do
64
+ let(:connec_name) { 'Credit Note' }
65
+ it { expect(subject.normalized_connec_entity_name).to eql('credit_note') }
66
+ end
67
+ end
68
+
69
+ context 'for a non singleton resource' do
70
+ before {
71
+ allow(subject).to receive(:singleton?).and_return(false)
72
+ }
103
73
 
74
+ context 'for a simple name' do
75
+ let(:connec_name) { 'Person' }
104
76
  it { expect(subject.normalized_connec_entity_name).to eql('people') }
105
77
  end
78
+
79
+ context 'for a complex name' do
80
+ let(:connec_name) { 'Credit Note' }
81
+ it { expect(subject.normalized_connec_entity_name).to eql('credit_notes') }
82
+ end
106
83
  end
84
+ end
85
+
86
+ describe 'id_from_external_entity_hash' do
87
+ it { expect{ subject.id_from_external_entity_hash(nil) }.to raise_error('Not implemented') }
88
+ end
89
+
90
+ describe 'last_update_date_from_external_entity_hash' do
91
+ it { expect{ subject.last_update_date_from_external_entity_hash(nil) }.to raise_error('Not implemented') }
92
+ end
93
+
94
+ # Entity specific methods
95
+ describe 'singleton?' do
96
+ it 'is false by default' do
97
+ expect(subject.singleton?).to be false
98
+ end
99
+ end
100
+
101
+ describe 'connec_entity_name' do
102
+ it { expect{ subject.connec_entity_name }.to raise_error('Not implemented') }
103
+ end
104
+
105
+ describe 'external_entity_name' do
106
+ it { expect{ subject.external_entity_name }.to raise_error('Not implemented') }
107
+ end
108
+
109
+ describe 'mapper_class' do
110
+ it { expect{ subject.mapper_class }.to raise_error('Not implemented') }
111
+ end
112
+
113
+ describe 'object_name_from_connec_entity_hash' do
114
+ it { expect{ subject.object_name_from_connec_entity_hash({}) }.to raise_error('Not implemented') }
115
+ end
116
+
117
+ describe 'object_name_from_external_entity_hash' do
118
+ it { expect{ subject.object_name_from_external_entity_hash({}) }.to raise_error('Not implemented') }
119
+ end
120
+ end
121
+
122
+ describe 'instance methods' do
123
+ subject { Maestrano::Connector::Rails::Entity.new }
124
+
125
+ describe 'Mapper methods' do
126
+ before(:each) {
127
+ class AMapper
128
+ extend HashMapper
129
+ end
130
+ allow(subject.class).to receive(:mapper_class).and_return(AMapper)
131
+ }
132
+
133
+ describe 'map_to_external' do
134
+ it 'calls the mapper normalize' do
135
+ expect(AMapper).to receive(:normalize).with({})
136
+ subject.map_to_external({}, nil)
137
+ end
138
+ end
139
+
140
+ describe 'map_to_connec' do
141
+ it 'calls the mapper denormalize' do
142
+ expect(AMapper).to receive(:denormalize).with({})
143
+ subject.map_to_connec({}, nil)
144
+ end
145
+ end
146
+ end
147
+
148
+ # Connec! methods
149
+ describe 'connec_methods' do
150
+ let(:organization) { create(:organization) }
151
+ let(:client) { Maestrano::Connec::Client.new(organization.uid) }
152
+ let(:connec_name) { 'Person' }
153
+ let(:external_name) { 'external_name' }
154
+ let(:sync) { create(:synchronization) }
155
+ before {
156
+ allow(subject.class).to receive(:connec_entity_name).and_return(connec_name)
157
+ allow(subject.class).to receive(:external_entity_name).and_return(external_name)
158
+ }
107
159
 
108
160
  describe 'get_connec_entities' do
109
161
 
@@ -111,7 +163,7 @@ describe Maestrano::Connector::Rails::Entity do
111
163
  context 'for a singleton resource' do
112
164
  before {
113
165
  allow(client).to receive(:get).and_return(ActionDispatch::Response.new(200, {}, {person: []}.to_json, {}))
114
- allow(subject).to receive(:singleton?).and_return(true)
166
+ allow(subject.class).to receive(:singleton?).and_return(true)
115
167
  }
116
168
 
117
169
  it 'calls get with a singularize url' do
@@ -188,7 +240,7 @@ describe Maestrano::Connector::Rails::Entity do
188
240
  describe 'push_entities_to_connec_to' do
189
241
  let(:organization) { create(:organization) }
190
242
  let(:idmap1) { create(:idmap, organization: organization) }
191
- let(:idmap2) { create(:idmap, organization: organization, connec_id: nil, connec_entity: nil, last_push_to_connec: nil) }
243
+ let(:idmap2) { create(:idmap, organization: organization, connec_id: nil, last_push_to_connec: nil) }
192
244
  let(:entity1) { {name: 'John'} }
193
245
  let(:entity2) { {name: 'Jane'} }
194
246
  let(:entity_with_idmap1) { {entity: entity1, idmap: idmap1} }
@@ -210,9 +262,14 @@ describe Maestrano::Connector::Rails::Entity do
210
262
  expect(idmap1.last_push_to_connec).to_not eql(old_push_date)
211
263
  idmap2.reload
212
264
  expect(idmap2.connec_id).to eql(id)
213
- expect(idmap2.connec_entity).to eql(connec_name.downcase)
214
265
  expect(idmap2.last_push_to_connec).to_not be_nil
215
266
  end
267
+
268
+ it 'stores an errr if any in the idmap' do
269
+ subject.push_entities_to_connec_to(client, entities_with_idmaps, '', organization)
270
+ idmap1.reload
271
+ expect(idmap1.message).to_not be nil
272
+ end
216
273
  end
217
274
 
218
275
  describe 'create_connec_entity' do
@@ -251,11 +308,11 @@ describe Maestrano::Connector::Rails::Entity do
251
308
  let(:id) { '765e-zer4' }
252
309
  let(:mapped_entity) { {'first_name' => 'John'} }
253
310
  before {
254
- allow(subject).to receive(:connec_entity_name).and_return(connec_name)
255
- allow(subject).to receive(:external_entity_name).and_return(external_name)
311
+ allow(subject.class).to receive(:connec_entity_name).and_return(connec_name)
312
+ allow(subject.class).to receive(:external_entity_name).and_return(external_name)
256
313
  allow(subject).to receive(:map_to_external).and_return(mapped_entity)
257
- allow(subject).to receive(:object_name_from_connec_entity_hash).and_return('name')
258
- allow(subject).to receive(:object_name_from_external_entity_hash).and_return('name')
314
+ allow(subject.class).to receive(:object_name_from_connec_entity_hash).and_return('name')
315
+ allow(subject.class).to receive(:object_name_from_external_entity_hash).and_return('name')
259
316
  }
260
317
 
261
318
  context 'when entity has an idmap' do
@@ -292,7 +349,7 @@ describe Maestrano::Connector::Rails::Entity do
292
349
  context 'when entity has no idmap' do
293
350
  let(:entity) { {'id' => id, 'name' => 'John', 'updated_at' => 5.hour.ago } }
294
351
  before {
295
- allow(subject).to receive(:object_name_from_connec_entity_hash).and_return('human readable stuff')
352
+ allow(subject.class).to receive(:object_name_from_connec_entity_hash).and_return('human readable stuff')
296
353
  }
297
354
 
298
355
  it { expect{ subject.map_to_external_with_idmap(entity, organization) }.to change{Maestrano::Connector::Rails::IdMap.count}.by(1) }
@@ -329,7 +386,7 @@ describe Maestrano::Connector::Rails::Entity do
329
386
 
330
387
  describe 'push_entities_to_external' do
331
388
  it 'calls push_entities_to_external_to' do
332
- allow(subject).to receive(:external_entity_name).and_return(external_name)
389
+ allow(subject.class).to receive(:external_entity_name).and_return(external_name)
333
390
  expect(subject).to receive(:push_entities_to_external_to).with(nil, entities_with_idmaps, external_name, organization)
334
391
  subject.push_entities_to_external(nil, entities_with_idmaps, organization)
335
392
  end
@@ -337,7 +394,7 @@ describe Maestrano::Connector::Rails::Entity do
337
394
 
338
395
  describe 'push_entities_to_external_to' do
339
396
  it 'calls push_entity_to_external for each entity' do
340
- allow(subject).to receive(:connec_entity_name).and_return(connec_name)
397
+ allow(subject.class).to receive(:connec_entity_name).and_return(connec_name)
341
398
  expect(subject).to receive(:push_entity_to_external).twice
342
399
  subject.push_entities_to_external_to(nil, entities_with_idmaps, external_name, organization)
343
400
  end
@@ -370,7 +427,6 @@ describe Maestrano::Connector::Rails::Entity do
370
427
  subject.push_entity_to_external(nil, entity_with_idmap2, external_name, organization)
371
428
  idmap2.reload
372
429
  expect(idmap2.external_id).to eql('999111')
373
- expect(idmap2.external_entity).to eql(external_name)
374
430
  expect(idmap2.last_push_to_external).to_not be_nil
375
431
  end
376
432
  end
@@ -387,14 +443,6 @@ describe Maestrano::Connector::Rails::Entity do
387
443
 
388
444
  it { expect{ subject.update_external_entity(nil, nil, nil, nil, organization) }.to raise_error('Not implemented') }
389
445
  end
390
-
391
- describe 'get_id_from_external_entity_hash' do
392
- it { expect{ subject.get_id_from_external_entity_hash(nil) }.to raise_error('Not implemented') }
393
- end
394
-
395
- describe 'get_last_update_date_from_external_entity_hash' do
396
- it { expect{ subject.get_last_update_date_from_external_entity_hash(nil) }.to raise_error('Not implemented') }
397
- end
398
446
  end
399
447
 
400
448
 
@@ -406,19 +454,19 @@ describe Maestrano::Connector::Rails::Entity do
406
454
  let(:id) { '56882' }
407
455
  let(:date) { 2.hour.ago }
408
456
  before {
409
- allow(subject).to receive(:get_id_from_external_entity_hash).and_return(id)
410
- allow(subject).to receive(:get_last_update_date_from_external_entity_hash).and_return(date)
411
- allow(subject).to receive(:external_entity_name).and_return(external_name)
412
- allow(subject).to receive(:connec_entity_name).and_return(connec_name)
457
+ allow(subject.class).to receive(:id_from_external_entity_hash).and_return(id)
458
+ allow(subject.class).to receive(:last_update_date_from_external_entity_hash).and_return(date)
459
+ allow(subject.class).to receive(:external_entity_name).and_return(external_name)
460
+ allow(subject.class).to receive(:connec_entity_name).and_return(connec_name)
413
461
  }
414
462
 
415
463
  context 'for a singleton method' do
416
464
  before {
417
- allow(subject).to receive(:singleton?).and_return(true)
465
+ allow(subject.class).to receive(:singleton?).and_return(true)
418
466
  allow(subject).to receive(:map_to_connec).and_return({map: 'connec'})
419
467
  allow(subject).to receive(:map_to_external).and_return({map: 'external'})
420
- allow(subject).to receive(:object_name_from_connec_entity_hash).and_return('connec human name')
421
- allow(subject).to receive(:object_name_from_external_entity_hash).and_return('external human name')
468
+ allow(subject.class).to receive(:object_name_from_connec_entity_hash).and_return('connec human name')
469
+ allow(subject.class).to receive(:object_name_from_external_entity_hash).and_return('external human name')
422
470
  }
423
471
 
424
472
  it { expect(subject.consolidate_and_map_data([], [], organization)).to eql({connec_entities: [], external_entities: []}) }
@@ -490,7 +538,7 @@ describe Maestrano::Connector::Rails::Entity do
490
538
 
491
539
  before {
492
540
  allow(subject).to receive(:map_to_connec).and_return(mapped_entity)
493
- allow(subject).to receive(:object_name_from_external_entity_hash).and_return(human_name)
541
+ allow(subject.class).to receive(:object_name_from_external_entity_hash).and_return(human_name)
494
542
  }
495
543
 
496
544
  context 'when entity has no idmap' do
@@ -587,34 +635,6 @@ describe Maestrano::Connector::Rails::Entity do
587
635
 
588
636
  end
589
637
  end
590
-
591
-
592
- # Entity specific methods
593
- describe 'singleton?' do
594
- it 'is false by default' do
595
- expect(subject.singleton?).to be false
596
- end
597
- end
598
-
599
- describe 'connec_entity_name' do
600
- it { expect{ subject.connec_entity_name }.to raise_error('Not implemented') }
601
- end
602
-
603
- describe 'external_entity_name' do
604
- it { expect{ subject.external_entity_name }.to raise_error('Not implemented') }
605
- end
606
-
607
- describe 'mapper_class' do
608
- it { expect{ subject.mapper_class }.to raise_error('Not implemented') }
609
- end
610
-
611
- describe 'object_name_from_connec_entity_hash' do
612
- it { expect{ subject.object_name_from_connec_entity_hash({}) }.to raise_error('Not implemented') }
613
- end
614
-
615
- describe 'object_name_from_external_entity_hash' do
616
- it { expect{ subject.object_name_from_external_entity_hash({}) }.to raise_error('Not implemented') }
617
- end
618
638
  end
619
639
 
620
640
  end
@@ -1,116 +1,122 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Maestrano::Connector::Rails::SubEntityBase do
4
- subject { Maestrano::Connector::Rails::SubEntityBase.new }
4
+ describe 'class methods' do
5
+ subject { Maestrano::Connector::Rails::SubEntityBase }
5
6
 
6
- describe 'external?' do
7
- it { expect{ subject.external? }.to raise_error('Not implemented') }
8
- end
7
+ describe 'external?' do
8
+ it { expect{ subject.external? }.to raise_error('Not implemented') }
9
+ end
9
10
 
10
- describe 'entity_name' do
11
- it { expect{ subject.entity_name }.to raise_error('Not implemented') }
12
- end
11
+ describe 'entity_name' do
12
+ it { expect{ subject.entity_name }.to raise_error('Not implemented') }
13
+ end
13
14
 
14
- describe 'map_to' do
15
- it { expect{ subject.map_to('name', {}, nil) }.to raise_error('Not implemented') }
16
- end
15
+ describe 'external_entity_name' do
16
+ context 'when entity is external' do
17
+ before(:each) {
18
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(true)
19
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
20
+ }
17
21
 
18
- describe 'external_entity_name' do
19
- context 'when entity is external' do
20
- before(:each) {
21
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(true)
22
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
23
- }
22
+ it 'returns the entity_name' do
23
+ expect(subject.external_entity_name).to eql('Name')
24
+ end
25
+ end
24
26
 
25
- it 'returns the entity_name' do
26
- expect(subject.external_entity_name).to eql('Name')
27
+ context 'when entity is not external' do
28
+ before {
29
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(false)
30
+ }
31
+ it { expect{ subject.external_entity_name }.to raise_error('Forbidden call: cannot call external_entity_name for a connec entity') }
27
32
  end
28
33
  end
29
34
 
30
- context 'when entity is not external' do
31
- before {
32
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(false)
33
- }
34
- it { expect{ subject.external_entity_name }.to raise_error('Forbidden call: cannot call external_entity_name for a connec entity') }
35
- end
36
- end
35
+ describe 'connec_entity_name' do
36
+ context 'when entity is not external' do
37
+ before(:each) {
38
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(false)
39
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
40
+ }
37
41
 
38
- describe 'connec_entity_name' do
39
- context 'when entity is not external' do
40
- before(:each) {
41
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(false)
42
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
43
- }
42
+ it 'returns the entity_name' do
43
+ expect(subject.connec_entity_name).to eql('Name')
44
+ end
45
+ end
44
46
 
45
- it 'returns the entity_name' do
46
- expect(subject.connec_entity_name).to eql('Name')
47
+ context 'when entity is external' do
48
+ before {
49
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(true)
50
+ }
51
+ it { expect{ subject.connec_entity_name }.to raise_error('Forbidden call: cannot call connec_entity_name for an external entity') }
47
52
  end
48
53
  end
49
54
 
50
- context 'when entity is external' do
55
+ describe 'names_hash' do
56
+ let(:bool) { true }
51
57
  before {
52
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(true)
58
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(bool)
59
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
53
60
  }
54
- it { expect{ subject.connec_entity_name }.to raise_error('Forbidden call: cannot call connec_entity_name for an external entity') }
61
+
62
+ context 'when external' do
63
+ it { expect(subject.names_hash).to eql({external_entity: 'name'}) }
64
+ end
65
+ context 'when not external' do
66
+ let(:bool) { false }
67
+ it { expect(subject.names_hash).to eql({connec_entity: 'name'}) }
68
+ end
55
69
  end
56
- end
57
70
 
58
- describe 'names_hash' do
59
- let(:bool) { true }
60
- before {
61
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(bool)
62
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
63
- }
71
+ describe 'create_idmap_from_external_entity' do
72
+ let(:organization) { create(:organization) }
73
+ let(:bool) { true }
74
+ before {
75
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(bool)
76
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
77
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:id_from_external_entity_hash).and_return('id')
78
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:object_name_from_external_entity_hash).and_return('object name')
79
+ }
64
80
 
65
- context 'when external' do
66
- it { expect(subject.names_hash).to eql({external_entity: 'name'}) }
67
- end
68
- context 'when not external' do
69
- let(:bool) { false }
70
- it { expect(subject.names_hash).to eql({connec_entity: 'name'}) }
81
+ context 'when external' do
82
+ it {
83
+ expect(Maestrano::Connector::Rails::IdMap).to receive(:create).with({:external_entity=>"name", :external_id=>"id", :name=>"object name", :connec_entity=>"lala", :organization_id=>1})
84
+ subject.create_idmap_from_external_entity({}, 'lala', organization)
85
+ }
86
+ end
87
+ context 'when not external' do
88
+ let(:bool) { false }
89
+ it { expect{ subject.create_idmap_from_external_entity({}, '', organization) }.to raise_error('Forbidden call: cannot call create_idmap_from_external_entity for a connec entity') }
90
+ end
71
91
  end
72
- end
73
92
 
74
- describe 'create_idmap_from_external_entity' do
75
- let(:organization) { create(:organization) }
76
- let(:bool) { true }
77
- before {
78
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(bool)
79
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
80
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:get_id_from_external_entity_hash).and_return('id')
81
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:object_name_from_external_entity_hash).and_return('object name')
82
- }
83
-
84
- context 'when external' do
85
- it {
86
- expect(Maestrano::Connector::Rails::IdMap).to receive(:create).with({:external_entity=>"name", :external_id=>"id", :name=>"object name", :connec_entity=>"lala", :organization_id=>1})
87
- subject.create_idmap_from_external_entity({}, 'lala', organization)
93
+ describe 'create_idmap_from_connec_entity' do
94
+ let(:organization) { create(:organization) }
95
+ let(:bool) { true }
96
+ before {
97
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(bool)
98
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
99
+ allow(Maestrano::Connector::Rails::SubEntityBase).to receive(:object_name_from_connec_entity_hash).and_return('object name')
88
100
  }
89
- end
90
- context 'when not external' do
91
- let(:bool) { false }
92
- it { expect{ subject.create_idmap_from_external_entity({}, '', organization) }.to raise_error('Forbidden call: cannot call create_idmap_from_external_entity for a connec entity') }
101
+
102
+ context 'when external' do
103
+ it { expect{ subject.create_idmap_from_connec_entity({}, '', organization) }.to raise_error('Forbidden call: cannot call create_idmap_from_connec_entity for an external entity') }
104
+ end
105
+ context 'when not external' do
106
+ let(:bool) { false }
107
+ it {
108
+ expect(Maestrano::Connector::Rails::IdMap).to receive(:create).with({:connec_entity=>"name", :connec_id=>"lili", :name=>"object name", :external_entity=>"lala", :organization_id=>1})
109
+ subject.create_idmap_from_connec_entity({'id' => 'lili'}, 'lala', organization)
110
+ }
111
+ end
93
112
  end
94
113
  end
95
114
 
96
- describe 'create_idmap_from_connec_entity' do
97
- let(:organization) { create(:organization) }
98
- let(:bool) { true }
99
- before {
100
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:external?).and_return(bool)
101
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:entity_name).and_return('Name')
102
- allow_any_instance_of(Maestrano::Connector::Rails::SubEntityBase).to receive(:object_name_from_connec_entity_hash).and_return('object name')
103
- }
104
-
105
- context 'when external' do
106
- it { expect{ subject.create_idmap_from_connec_entity({}, '', organization) }.to raise_error('Forbidden call: cannot call create_idmap_from_connec_entity for an external entity') }
107
- end
108
- context 'when not external' do
109
- let(:bool) { false }
110
- it {
111
- expect(Maestrano::Connector::Rails::IdMap).to receive(:create).with({:connec_entity=>"name", :connec_id=>"lili", :name=>"object name", :external_entity=>"lala", :organization_id=>1})
112
- subject.create_idmap_from_connec_entity({'id' => 'lili'}, 'lala', organization)
113
- }
115
+ describe 'instance methods' do
116
+ subject { Maestrano::Connector::Rails::SubEntityBase.new }
117
+
118
+ describe 'map_to' do
119
+ it { expect{ subject.map_to('name', {}, nil) }.to raise_error('Not implemented') }
114
120
  end
115
121
  end
116
122
  end