npo_assets 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -4,11 +4,11 @@ module NPO
4
4
  include HTTParty
5
5
  format :xml
6
6
 
7
- attr_accessor :file, :url
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'].to_i)
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 => @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[:base] << msg }
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{npo_assets}
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
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"]
@@ -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(:url => "remote_url")
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 == ["File must be set."]
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 == ["File must be set."]
146
+ @asset.errors[:base].should == "File must be set."
147
147
  end
148
148
  end
149
149
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bart Zonneveld