npo_assets 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/npo_assets/asset.rb +5 -5
- data/npo_assets.gemspec +1 -1
- data/spec/npo_assets/asset_spec.rb +10 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/npo_assets/asset.rb
CHANGED
@@ -11,11 +11,11 @@ module NPO
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
def list(account_name=nil, options={})
|
14
|
-
url = "#{ NPO::Assets.base_url }.xml#{ extract_list_options(options) }"
|
14
|
+
url = "#{ NPO::Assets.base_url }/assets.xml#{ extract_list_options(options) }"
|
15
15
|
res = get(url, :headers => headers(account_name))
|
16
16
|
|
17
17
|
if res && res['assets']
|
18
|
-
res['assets']['asset'].
|
18
|
+
res['assets']['asset'].map do |vars|
|
19
19
|
create(:url => vars['url'], :remote_id => vars['id'])
|
20
20
|
end
|
21
21
|
else
|
@@ -37,7 +37,7 @@ module NPO
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def url(size='')
|
40
|
-
File.join(NPO::Assets.base_url, size, attributes['url'])
|
40
|
+
File.join(NPO::Assets.base_url, 'assets', size, attributes['url'])
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
@@ -46,7 +46,7 @@ module NPO
|
|
46
46
|
# run due to saving an imported asset
|
47
47
|
return true if self.remote_id && new_record?
|
48
48
|
|
49
|
-
url = [NPO::Assets.base_url]
|
49
|
+
url = [NPO::Assets.base_url, 'assets']
|
50
50
|
url << self.remote_id unless new_record?
|
51
51
|
|
52
52
|
response = self.class.send(new_record? ? :post : :put,
|
@@ -63,7 +63,7 @@ module NPO
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def delete_from_media_server
|
66
|
-
HTTParty.delete("#{NPO::Assets.base_url}/#{self.remote_id}", :headers => self.class.headers)
|
66
|
+
HTTParty.delete("#{NPO::Assets.base_url}/assets/#{self.remote_id}", :headers => self.class.headers)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
data/npo_assets.gemspec
CHANGED
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe NPO::Assets::Asset do
|
4
4
|
before(:all) do
|
5
5
|
setup_db
|
6
|
-
NPO::Assets.base_url = 'http://test.com
|
6
|
+
NPO::Assets.base_url = 'http://test.com'
|
7
7
|
NPO::Assets.account_name = 'account'
|
8
8
|
end
|
9
9
|
|
@@ -220,6 +220,11 @@ describe NPO::Assets::Asset do
|
|
220
220
|
"asset"=>[{"name"=>"bach", "url"=>"000/000/001.jpg", "id"=>"1"},
|
221
221
|
{"name"=>"bach", "url"=>"000/000/002.jpg", "id"=>"2"}]}}
|
222
222
|
|
223
|
+
@object1 = mock("Asset")
|
224
|
+
@object2 = mock("Asset")
|
225
|
+
NPO::Assets::Asset.stub!(:create).with(:url => "000/000/001.jpg", :remote_id => "1").and_return @object1
|
226
|
+
NPO::Assets::Asset.stub!(:create).with(:url => "000/000/002.jpg", :remote_id => "2").and_return @object2
|
227
|
+
|
223
228
|
NPO::Assets::Asset.stub!(:get).and_return @response
|
224
229
|
end
|
225
230
|
|
@@ -243,6 +248,10 @@ describe NPO::Assets::Asset do
|
|
243
248
|
NPO::Assets::Asset.should_not_receive(:put)
|
244
249
|
do_list
|
245
250
|
end
|
251
|
+
|
252
|
+
it "should return the created objects" do
|
253
|
+
do_list.should == [@object1, @object2]
|
254
|
+
end
|
246
255
|
end
|
247
256
|
end
|
248
257
|
end
|