npo_assets 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -58,7 +58,8 @@ module NPO
58
58
  response['errors']['error'].each { |msg| errors.add_to_base(msg) }
59
59
  false
60
60
  else
61
- self.url = response['asset']['url']
61
+ self.url = response['asset']['url']
62
+ self.remote_id = response['asset']['id']
62
63
  true
63
64
  end
64
65
  end
data/npo_assets.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{npo_assets}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bart Zonneveld"]
@@ -59,6 +59,11 @@ describe NPO::Assets::Asset do
59
59
  do_create
60
60
  @asset.attributes['url'].should == '000/000/000.jpg'
61
61
  end
62
+
63
+ it "should assign the id as remote id to the asset" do
64
+ do_create
65
+ @asset.attributes['remote_id'].should == 1
66
+ end
62
67
 
63
68
  it "should save the asset" do
64
69
  do_create
@@ -225,13 +230,8 @@ describe NPO::Assets::Asset do
225
230
  describe "response" do
226
231
  before(:each) do
227
232
  @response = {"assets"=>{"results"=>"2", "total_pages"=>"1",
228
- "asset"=>[{"name"=>"bach", "url"=>"000/000/001.jpg", "id"=>"1"},
229
- {"name"=>"bach", "url"=>"000/000/002.jpg", "id"=>"2"}]}}
230
-
231
- @object1 = mock("Asset")
232
- @object2 = mock("Asset")
233
- NPO::Assets::Asset.stub!(:find_or_create_by_url_and_remote_id).with("000/000/001.jpg", 1).and_return @object1
234
- NPO::Assets::Asset.stub!(:find_or_create_by_url_and_remote_id).with("000/000/002.jpg", 2).and_return @object2
233
+ "asset"=>[{"name"=>"bach", "url"=>"000/000/001.jpg", "id"=>"10"},
234
+ {"name"=>"bach", "url"=>"000/000/002.jpg", "id"=>"20"}]}}
235
235
 
236
236
  NPO::Assets::Asset.stub!(:get).and_return @response
237
237
  end
@@ -246,8 +246,8 @@ describe NPO::Assets::Asset do
246
246
  end
247
247
 
248
248
  it "should generate new assets for each returned asset" do
249
- NPO::Assets::Asset.should_receive(:find_or_create_by_url_and_remote_id).with("000/000/001.jpg", 1).once
250
- NPO::Assets::Asset.should_receive(:find_or_create_by_url_and_remote_id).with("000/000/002.jpg", 2).once
249
+ NPO::Assets::Asset.should_receive(:find_or_create_by_url_and_remote_id).with("000/000/001.jpg", 10).once
250
+ NPO::Assets::Asset.should_receive(:find_or_create_by_url_and_remote_id).with("000/000/002.jpg", 20).once
251
251
  do_list
252
252
  end
253
253
 
@@ -257,8 +257,14 @@ describe NPO::Assets::Asset do
257
257
  do_list
258
258
  end
259
259
 
260
+ it "should save the assets with the correct attributes" do
261
+ do_list
262
+ NPO::Assets::Asset.first.attributes.should == {"remote_id" => 10, "url" => "000/000/001.jpg", "id" => 1}
263
+ NPO::Assets::Asset.last.attributes.should == {"remote_id" => 20, "url" => "000/000/002.jpg", "id" => 2}
264
+ end
265
+
260
266
  it "should return the created objects" do
261
- do_list.should == [@object1, @object2]
267
+ do_list.should == NPO::Assets::Asset.all
262
268
  end
263
269
  end
264
270
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bart Zonneveld