npo_assets 0.1.5 → 0.2.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.1.5
1
+ 0.2.0
@@ -4,7 +4,7 @@ module NPO
4
4
  include HTTParty
5
5
  format :xml
6
6
 
7
- attr_accessor :file
7
+ attr_accessor :file, :url
8
8
 
9
9
  before_save :post_to_media_server
10
10
  after_destroy :delete_from_media_server
@@ -49,9 +49,10 @@ 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
53
  response = self.class.send(new_record? ? :post : :put,
53
54
  url.join('/'),
54
- :query => { :asset => { :file => @file } },
55
+ :query => { :asset => attrs },
55
56
  :headers => self.class.headers)
56
57
  if response.code == 422
57
58
  response['errors']['error'].each { |msg| errors[:base] << msg }
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.1.5"
8
+ s.version = "0.2.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"]
@@ -24,12 +24,20 @@ describe NPO::Assets::Asset do
24
24
  @asset.save
25
25
  end
26
26
 
27
- it "should send the correct vars" do
27
+ it "should send the correct vars with a file upload" do
28
28
  NPO::Assets::Asset.should_receive(:post).with("http://test.com/assets",
29
29
  :query => {:asset => {:file => "file"}},
30
30
  :headers => {'X-Account' => 'account'})
31
31
  do_create
32
32
  end
33
+
34
+ it "should send the correct vars with a remote url" do
35
+ asset = NPO::Assets::Asset.new(:url => "remote_url")
36
+ NPO::Assets::Asset.should_receive(:post).with("http://test.com/assets",
37
+ :query => {:asset => {:url => "remote_url"}},
38
+ :headers => {'X-Account' => 'account'})
39
+ asset.save
40
+ end
33
41
 
34
42
  describe "with successfull save" do
35
43
  before(:each) do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 5
9
- version: 0.1.5
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bart Zonneveld