tms_bridge 0.1 → 0.1.1
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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/tms_bridge/controller_support.rb +5 -1
- data/lib/tms_bridge/version.rb +1 -1
- data/spec/tms_bridge/controller_support_spec.rb +17 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGM4YzdjNmQ4MmMyZTNiN2Q5YTZjOTNkMGEzNDk2ZjI4YTMwZGM5OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjA5ZWEwOTZmMDQ3MDg0MDM5OTg2M2E2MTc4ZGI1M2U2NGZlZWI5OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmM2MDRmMjM4MzQ0MTQzNWY0ZWM1YzIxNjE1ZjQ1YjMzYWQxODA2ZDkyNTE2
|
10
|
+
ZTdjYzc2MDhjNWNkYjU1YmMwMzA3NjA3YTljMzY4NzVkODg1YTFkYTQzZmRm
|
11
|
+
YzIzNDY1Y2EyZGViYTdiZjYyYTc4Nzc3N2EzMGQyZGVkZjE2ZTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWQzNWNmY2U4MjY0NzY3ZTIwNmNmMmNiYTZjY2NlMzY5ZmVjZmU0Y2VlM2Vi
|
14
|
+
NWUxZmUyZTRkMjI2NzIyNGQyZTk2M2MzMjY0M2QzNTNiOGY2Yzg2NTIwMDMx
|
15
|
+
ZjNmNDY1MTk0MDhjMDBjODNhYzhmMGFiZGZmMDQ5ODIxYWQwZGM=
|
data/Gemfile.lock
CHANGED
@@ -53,7 +53,11 @@ RUBY
|
|
53
53
|
self.update_only = options[:update_only]
|
54
54
|
class_eval <<-RUBY, __FILE__, __LINE__+1
|
55
55
|
def create
|
56
|
-
@#{self.bridged_resource} =
|
56
|
+
@#{self.bridged_resource} = #{class_name}.find_by_tms_id(@json['tms_id'])
|
57
|
+
|
58
|
+
if @#{self.bridged_resource}.nil? && #{class_name}.column_names.include?('bridge_id') && !@json['bridge_id'].blank?
|
59
|
+
@#{self.bridged_resource} = #{class_name}.find_by_bridge_id(@json['bridge_id'])
|
60
|
+
end
|
57
61
|
|
58
62
|
@#{self.bridged_resource} = #{class_name}.new if @#{self.bridged_resource}.nil? && !self.update_only?
|
59
63
|
if @#{self.bridged_resource}
|
data/lib/tms_bridge/version.rb
CHANGED
@@ -217,7 +217,8 @@ describe TmsBridge::ControllerSupport::Publish do
|
|
217
217
|
before(:each) do
|
218
218
|
@attributes = {'some_key'=>'some value'}
|
219
219
|
@tms_id = MockPublishing::NOT_FOUND
|
220
|
-
|
220
|
+
@bridge_id = 'somebridgeid'
|
221
|
+
controller.json = {'mock_publishing'=>@attributes, 'tms_id'=>@tms_id, 'bridge_id'=>@bridge_id}
|
221
222
|
end
|
222
223
|
|
223
224
|
it "should assign to the mock_publishing attribute" do
|
@@ -241,7 +242,6 @@ describe TmsBridge::ControllerSupport::Publish do
|
|
241
242
|
end
|
242
243
|
|
243
244
|
it "should not pass attributes to the mock model taht are not supported" do
|
244
|
-
puts MockPublishing.published_attribute_names
|
245
245
|
MockPublishing.should_receive(:published_attribute_names){['some_key']}
|
246
246
|
controller.create
|
247
247
|
end
|
@@ -269,13 +269,21 @@ describe TmsBridge::ControllerSupport::Publish do
|
|
269
269
|
controller.create
|
270
270
|
end
|
271
271
|
|
272
|
-
it "should
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
272
|
+
it "should attempt a lookup of the model with bridge_id if not found by tms_id an supports bridge_id" do
|
273
|
+
MockPublishing.should_receive(:find_by_tms_id).with(@tms_id){nil}
|
274
|
+
column_names = MockPublishing.column_names + ['bridge_id']
|
275
|
+
MockPublishing.stub(:column_names){column_names}
|
276
|
+
MockPublishing.should_receive(:find_by_bridge_id).with(@bridge_id)
|
277
|
+
controller.create
|
278
|
+
end
|
279
|
+
|
280
|
+
it "should attempt a lookup of the model with bridge_id if not found by tms_id an supports bridge_id, but bridge_id is blank" do
|
281
|
+
MockPublishing.should_receive(:find_by_tms_id).with(@tms_id){nil}
|
282
|
+
column_names = MockPublishing.column_names + ['bridge_id']
|
283
|
+
MockPublishing.stub(:column_names){column_names}
|
284
|
+
MockPublishing.should_not_receive(:find_by_bridge_id).with(@bridge_id)
|
285
|
+
controller.json['bridge_id'] = nil
|
286
|
+
controller.create
|
279
287
|
end
|
280
288
|
|
281
289
|
end
|