npo_assets 0.2.1 → 0.3.0
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 +5 -5
- data/npo_assets.gemspec +1 -1
- data/spec/npo_assets/asset_spec.rb +3 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/npo_assets/asset.rb
CHANGED
@@ -4,11 +4,11 @@ module NPO
|
|
4
4
|
include HTTParty
|
5
5
|
format :xml
|
6
6
|
|
7
|
-
attr_accessor :file, :
|
7
|
+
attr_accessor :file, :remote_url
|
8
8
|
|
9
9
|
before_save :post_to_media_server
|
10
10
|
after_destroy :delete_from_media_server
|
11
|
-
|
11
|
+
|
12
12
|
class << self
|
13
13
|
def list(account_name=nil, options={})
|
14
14
|
url = "#{ NPO::Assets.base_url }/assets.xml#{ extract_list_options(options) }"
|
@@ -16,7 +16,7 @@ module NPO
|
|
16
16
|
|
17
17
|
if res && res['assets']
|
18
18
|
res['assets']['asset'].map do |vars|
|
19
|
-
find_or_create_by_url_and_remote_id(vars['url'], vars['id']
|
19
|
+
find_or_create_by_url_and_remote_id(vars['url'], vars['id'])
|
20
20
|
end
|
21
21
|
else
|
22
22
|
[]
|
@@ -49,13 +49,13 @@ module NPO
|
|
49
49
|
url = [NPO::Assets.base_url, 'assets']
|
50
50
|
url << self.remote_id unless new_record?
|
51
51
|
|
52
|
-
attrs = @file ? {:file => @file} : {:url => @
|
52
|
+
attrs = @file ? {:file => @file} : {:url => @remote_url}
|
53
53
|
response = self.class.send(new_record? ? :post : :put,
|
54
54
|
url.join('/'),
|
55
55
|
:query => { :asset => attrs },
|
56
56
|
:headers => self.class.headers)
|
57
57
|
if response.code == 422
|
58
|
-
response['errors']['error'].each { |msg| errors
|
58
|
+
response['errors']['error'].each { |msg| errors.add_to_base(msg) }
|
59
59
|
false
|
60
60
|
else
|
61
61
|
self.url = response['asset']['url']
|
data/npo_assets.gemspec
CHANGED
@@ -32,7 +32,7 @@ describe NPO::Assets::Asset do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should send the correct vars with a remote url" do
|
35
|
-
asset = NPO::Assets::Asset.new(:
|
35
|
+
asset = NPO::Assets::Asset.new(:remote_url => "remote_url")
|
36
36
|
NPO::Assets::Asset.should_receive(:post).with("http://test.com/assets",
|
37
37
|
:query => {:asset => {:url => "remote_url"}},
|
38
38
|
:headers => {'X-Account' => 'account'})
|
@@ -84,7 +84,7 @@ describe NPO::Assets::Asset do
|
|
84
84
|
|
85
85
|
it "should add the error to the asset" do
|
86
86
|
do_create
|
87
|
-
@asset.errors[:base].should ==
|
87
|
+
@asset.errors[:base].should == "File must be set."
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -143,7 +143,7 @@ describe NPO::Assets::Asset do
|
|
143
143
|
|
144
144
|
it "should add the error to the asset" do
|
145
145
|
do_update
|
146
|
-
@asset.errors[:base].should ==
|
146
|
+
@asset.errors[:base].should == "File must be set."
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|