tms_bridge 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDhkZTljM2VlM2FhM2Y0N2EwYWJkNTdkYjIzMThlZDhkNzVmOGJmOQ==
4
+ ZGM4YzdjNmQ4MmMyZTNiN2Q5YTZjOTNkMGEzNDk2ZjI4YTMwZGM5OA==
5
5
  data.tar.gz: !binary |-
6
- NjEyNjFlYWIzY2RlNDllZDJjYWQxZWM0YThkNWQxMTgwZTVkMzIxNQ==
6
+ NjA5ZWEwOTZmMDQ3MDg0MDM5OTg2M2E2MTc4ZGI1M2U2NGZlZWI5OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmQ3NzhmNzMyODM1OTEzNTdmYThmYWJiOTM1ZWViYTNlYzY5YzQxM2M0NTE3
10
- ODI0ZTFmZmI1YjZiYjBkODEwMGY3MTkwNjU2MzdkZTkzYjIyY2ZiMmZhNWVl
11
- NjIxMzIwMzA1ZmI4ZTRiM2Y5MjAxMTY5MGNmZjI3NGJlMGYzOGI=
9
+ ZmM2MDRmMjM4MzQ0MTQzNWY0ZWM1YzIxNjE1ZjQ1YjMzYWQxODA2ZDkyNTE2
10
+ ZTdjYzc2MDhjNWNkYjU1YmMwMzA3NjA3YTljMzY4NzVkODg1YTFkYTQzZmRm
11
+ YzIzNDY1Y2EyZGViYTdiZjYyYTc4Nzc3N2EzMGQyZGVkZjE2ZTA=
12
12
  data.tar.gz: !binary |-
13
- YTRiMDgxNWM4MDU2MDVhYjVhNTg2ZDBlMGExNTMyM2Y4ODdmZWQyZDRhNDgy
14
- YjcyZmFhMjA4MGE0N2Q4NGRhMWY4ZTZhMjExZmM3MGFlYmE1NDcxNTNkZjZl
15
- MjIwYjMwNjYzMjFjMmQ5N2MyODJlMzYyMGE3OTBkNDIwMGVkMGY=
13
+ NWQzNWNmY2U4MjY0NzY3ZTIwNmNmMmNiYTZjY2NlMzY5ZmVjZmU0Y2VlM2Vi
14
+ NWUxZmUyZTRkMjI2NzIyNGQyZTk2M2MzMjY0M2QzNTNiOGY2Yzg2NTIwMDMx
15
+ ZjNmNDY1MTk0MDhjMDBjODNhYzhmMGFiZGZmMDQ5ODIxYWQwZGM=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tms_bridge (0.1)
4
+ tms_bridge (0.1.1)
5
5
  actionpack (>= 3.2.0)
6
6
  activerecord (>= 3.2.0)
7
7
  iron_cache
@@ -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} = block_given? ? yield(#{class_name}, @json) : #{class_name}.find_by_tms_id(@json['tms_id'])
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}
@@ -1,3 +1,3 @@
1
1
  module Bridge
2
- VERSION = "0.1"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- controller.json = {'mock_publishing'=>@attributes, 'tms_id'=>@tms_id}
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 yield to find a model if block_given?" do
273
- yielded = false
274
- controller.create{
275
- yielded = true
276
- nil
277
- }
278
- yielded.should == true
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tms_bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Timkar