npo_assets 0.3.1 → 0.3.2
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.
- data/VERSION +1 -1
- data/lib/npo_assets/asset.rb +2 -1
- data/npo_assets.gemspec +1 -1
- data/spec/npo_assets/asset_spec.rb +16 -10
- metadata +2 -2
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.2
|
data/lib/npo_assets/asset.rb
CHANGED
data/npo_assets.gemspec
CHANGED
|
@@ -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"=>"
|
|
229
|
-
{"name"=>"bach", "url"=>"000/000/002.jpg", "id"=>"
|
|
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",
|
|
250
|
-
NPO::Assets::Asset.should_receive(:find_or_create_by_url_and_remote_id).with("000/000/002.jpg",
|
|
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 ==
|
|
267
|
+
do_list.should == NPO::Assets::Asset.all
|
|
262
268
|
end
|
|
263
269
|
end
|
|
264
270
|
end
|