cloudapp_api 0.1.1 → 0.2.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.
@@ -0,0 +1,197 @@
1
+ module CloudApp
2
+
3
+ # An ActiveResource-like interface through which to interract with CloudApp drops.
4
+ #
5
+ # @example Gets started by Authenticating
6
+ # CloudApp.authenticate "username", "password"
7
+ #
8
+ # @example Usage via the Drop class
9
+ # # Find a single drop by it's slug
10
+ # @drop = CloudApp::Drop.find "2wr4"
11
+ #
12
+ # # Get a list of all drops
13
+ # @drops = CloudApp::Drop.all
14
+ #
15
+ # # Create a new bookmark
16
+ # @drop = CloudApp::Drop.create :bookmark, :name => "CloudApp", :redirect_url => "http://getcloudapp.com"
17
+ #
18
+ # # Create multiple bookmarks
19
+ # bookmarks = [
20
+ # { :name => "Authur Dent", :redirect_url => "http://en.wikipedia.org/wiki/Arthur_Dent" },
21
+ # { :name => "Zaphod Beeblebrox", :redirect_url => "http://en.wikipedia.org/wiki/Zaphod_Beeblebrox" }
22
+ # ]
23
+ # @drops = CloudApp::Drop.create :bookmarks, bookmarks
24
+ #
25
+ # # Upload a file
26
+ # @drop = CloudApp::Drop.create :upload, :file => "/path/to/image.png"
27
+ # @drop = CloudApp::Drop.create :upload, :file => "/path/to/image.png", :private => true
28
+ #
29
+ # # Rename a file
30
+ # CloudApp::Drop.update "http://my.cl.ly/items/1912565", :name => "Big Screenshot"
31
+ #
32
+ # # Set a drop's privacy
33
+ # CloudApp::Drop.update "http://my.cl.ly/items/1912565", :private => true
34
+ #
35
+ # # Delete a drop
36
+ # CloudApp::Drop.delete "http://my.cl.ly/items/1912565"
37
+ #
38
+ # # Recover a deleted drop
39
+ # CloudApp::Drop.recover "http://my.cl.ly/items/1912565"
40
+ #
41
+ # @example Usage via the class instance
42
+ # # Rename a file
43
+ # @drop.update :name => "Big Screenshot"
44
+ #
45
+ # # Set the drop's privacy
46
+ # @drop.update :private => true
47
+ #
48
+ # # Delete a drop
49
+ # @drop.delete
50
+ #
51
+ # # Recover a deleted drop
52
+ # @drop.recover
53
+ #
54
+ class Drop < Base
55
+
56
+ # Get metadata about a cl.ly URL like name, type, or view count.
57
+ #
58
+ # Finds the drop by it's slug id, for example "2wr4".
59
+ #
60
+ # @param [String] id cl.ly slug id
61
+ # @return [CloudApp::Drop]
62
+ def self.find(id)
63
+ res = get "http://cl.ly/#{id}"
64
+ res.ok? ? Drop.new(res) : res
65
+ end
66
+
67
+ # Page through your drops.
68
+ #
69
+ # Requires authentication.
70
+ #
71
+ # @param [Hash] opts options parameters
72
+ # @option opts [Integer] :page Page number starting at 1
73
+ # @option opts [Integer] :per_page Number of items per page
74
+ # @option opts [String] :type Filter items by type (image, bookmark, text, archive, audio, video, or unknown)
75
+ # @option opts [Boolean] :deleted Show trashed drops
76
+ # @return [Array[CloudApp::Drop]]
77
+ def self.all(opts = {})
78
+ res = get "/items", {:query => (opts.empty? ? nil : opts), :digest_auth => @@auth}
79
+ res.ok? ? res.collect{|i| Drop.new(i)} : res
80
+ end
81
+
82
+ # Create a new drop. Multiple bookmarks can be created at once by
83
+ # passing an array of bookmark options parameters.
84
+ #
85
+ # Requires authentication.
86
+ #
87
+ # @param [Symbol] kind type of drop (can be +:bookmark+, +:bookmarks+ or +:upload+)
88
+ # @overload self.create(:bookmark, opts = {})
89
+ # @param [Hash] opts options paramaters
90
+ # @option opts [String] :name Name of bookmark (only required for +:bookmark+ kind)
91
+ # @option opts [String] :redirect_url Redirect URL (only required for +:bookmark+ kind)
92
+ # @overload self.create(:bookmarks, bookmarks)
93
+ # @param [Array] bookmarks array of bookmark option parameters (containing +:name+ and +:redirect_url+)
94
+ # @overload self.create(:upload, opts = {})
95
+ # @param [Hash] opts options paramaters
96
+ # @option opts [String] :file Path to file (only required for +:upload+ kind)
97
+ # @option opts [Boolean] :private override the account default privacy setting
98
+ # @return [CloudApp::Drop]
99
+ def self.create(kind, opts = {})
100
+ case kind
101
+ when :bookmark
102
+ res = post "/items", {:body => {:item => opts}, :digest_auth => @@auth}
103
+ when :bookmarks
104
+ res = post "/items", {:body => {:items => opts}, :digest_auth => @@auth}
105
+ when :upload
106
+ r = get "/items/new", {:query => ({:item => {:private => opts[:private]}} if opts.has_key?(:private)), :digest_auth => @@auth}
107
+ return r unless r.ok?
108
+ res = post r['url'], Multipart.new(r['params'].merge!(:file => File.new(opts[:file]))).payload.merge!(:digest_auth => @@auth)
109
+ else
110
+ # TODO raise an error
111
+ return false
112
+ end
113
+ res.ok? ? (res.is_a?(Array) ? res.collect{|i| Drop.new(i)} : Drop.new(res)) : res
114
+ end
115
+
116
+ # Modify a drop. Can currently modify it's name or security setting by passing parameters.
117
+ #
118
+ # Requires authentication.
119
+ #
120
+ # @param [String] href href attribute of drop
121
+ # @param [Hash] opts options paramaters
122
+ # @option opts [String] :name for renaming the drop
123
+ # @option opts [Boolean] :privacy set drop privacy
124
+ # @return [CloudApp::Drop]
125
+ def self.update(href, opts = {})
126
+ res = put href, {:body => {:item => opts}, :digest_auth => @@auth}
127
+ res.ok? ? Drop.new(res) : res
128
+ end
129
+
130
+ # Send a drop to the trash.
131
+ #
132
+ # Requires authentication.
133
+ #
134
+ # @param [String] href href attribute of the drop
135
+ # @return [CloudApp::Drop]
136
+ def self.delete(href)
137
+ # Use delete on the Base class to avoid recursion
138
+ res = Base.delete href, :digest_auth => @@auth
139
+ res.ok? ? Drop.new(res) : res
140
+ end
141
+
142
+ # Recover a drop from the trash.
143
+ #
144
+ # Requires authentication.
145
+ #
146
+ # @param [String] href href attribute of the drop
147
+ # @return [CloudApp::Drop]
148
+ def self.recover(href)
149
+ res = put href, {:body => {:deleted => true, :item => {:deleted_at => nil}}, :digest_auth => @@auth}
150
+ res.ok? ? Drop.new(res) : res
151
+ end
152
+
153
+ attr_reader :href, :name, :private, :url, :content_url, :item_type, :view_counter,
154
+ :icon, :remote_url, :redirect_url, :created_at, :updated_at, :deleted_at
155
+
156
+ # Create a new CloudApp::Drop object.
157
+ #
158
+ # Only used internally.
159
+ #
160
+ # @param [Hash] attributes
161
+ # @param [CloudApp::Drop]
162
+ def initialize(attributes = {})
163
+ load(attributes)
164
+ end
165
+
166
+ # Modify the drop. Can currently modify it's name or security setting by passing parameters.
167
+ #
168
+ # @param [Hash] opts options paramaters
169
+ # @option opts [String] :name for renaming the drop
170
+ # @option opts [Boolean] :privacy set the drop's privacy
171
+ # @return [CloudApp::Drop]
172
+ def update(opts = {})
173
+ self.class.update self.href, opts
174
+ end
175
+
176
+ # Send the drop to the trash.
177
+ #
178
+ # @return [CloudApp::Drop]
179
+ def delete
180
+ self.class.delete self.href
181
+ end
182
+
183
+ # Recover the drop from the trash.
184
+ #
185
+ # @return [CloudApp::Drop]
186
+ def recover
187
+ self.class.recover self.href
188
+ end
189
+
190
+ end
191
+
192
+ # The Item class is now deprecated in favour of the Drop class.
193
+ # For legacy purposes you can still use the Item class but it is recommended you
194
+ # update your code to use the Drop class to ensure future compatibility.
195
+ class Item < Drop; end
196
+
197
+ end
@@ -0,0 +1,64 @@
1
+ module CloudApp
2
+
3
+ # An ActiveResource-like interface through which to interract with CloudApp gift cards.
4
+ #
5
+ #
6
+ # @example Gets started by Authenticating
7
+ # CloudApp.authenticate "username", "password"
8
+ #
9
+ # @example Usage via the GiftCard class
10
+ # # View gift card details
11
+ # @gift = CloudApp::GiftCard.find "ABC123"
12
+ #
13
+ # # Apply the gift card
14
+ # CloudApp::GiftCard.redeem "ABC123"
15
+ # # or
16
+ # @gift.redeem
17
+ #
18
+ class GiftCard < Base
19
+
20
+ # Get the details of an unredeemed gift card.
21
+ #
22
+ # Requires authentication.
23
+ #
24
+ # @param [String] code Gift card code
25
+ # @return [CloudApp::GiftCard]
26
+ def self.find(code)
27
+ res = get "/gift_cards/#{code}", :digest_auth => @@auth
28
+ res.ok? ? GiftCard.new(res) : res
29
+ end
30
+
31
+ # Apply a gift card to the authenticated account.
32
+ #
33
+ # Requires authentication.
34
+ #
35
+ # @param [String] code Gift card code
36
+ # @return [CloudApp::GiftCard]
37
+ def self.redeem(code)
38
+ res = put "/gift_cards/#{code}", :digest_auth => @@auth
39
+ res.ok? ? GiftCard.new(res) : res
40
+ end
41
+
42
+ attr_reader :id, :code, :plan, :months, :href,
43
+ :created_at, :updated_at, :redeemed_at, :effective_at, :expires_at
44
+
45
+ # Create a new CloudApp::GiftCard object.
46
+ #
47
+ # Only used internally
48
+ #
49
+ # @param [Hash] attributes
50
+ # @param [CloudApp::GiftCard]
51
+ def initialize(attributes = {})
52
+ load(attributes)
53
+ end
54
+
55
+ # Apply the gift card to the authenticated account.
56
+ #
57
+ # @return [CloudApp::GiftCard]
58
+ def redeem
59
+ self.class.redeem code
60
+ end
61
+
62
+ end
63
+
64
+ end
data/lib/cloudapp_api.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "httparty"
2
2
 
3
- ["base", "item", "account", "client", "multipart", "httparty"].each do |inc|
3
+ ["base", "drop", "account", "gift_card", "client", "multipart", "httparty", "core_ext"].each do |inc|
4
4
  require File.join(File.dirname(__FILE__), "cloudapp", inc)
5
5
  end
6
6
 
@@ -10,15 +10,15 @@ end
10
10
  module CloudApp
11
11
 
12
12
  # Version number
13
- VERSION = "0.1.0"
13
+ VERSION = "0.2.0"
14
14
 
15
15
  # Sets the authentication credentials in a class variable
16
16
  #
17
- # @param [String] username cl.ly username
17
+ # @param [String] email cl.ly username
18
18
  # @param [String] password cl.ly password
19
19
  # @return [Hash] authentication credentials
20
- def CloudApp.authenticate(username, password)
21
- Base.authenticate(username, password)
20
+ def CloudApp.authenticate(email, password)
21
+ Base.authenticate(email, password)
22
22
  end
23
23
 
24
24
  end
@@ -122,14 +122,14 @@ describe "Register account" do
122
122
  before(:each) do
123
123
  fake_it_all
124
124
  @email = "arthur@dent.com"
125
- @account = CloudApp::Account.create :email => @email, :current_password => "towel"
125
+ @account = CloudApp::Account.create :email => @email, :current_password => "towel", :accept_tos => true
126
126
  end
127
127
 
128
128
  it "should be a Account object" do
129
129
  @account.should be_a_kind_of CloudApp::Account
130
130
  end
131
131
 
132
- it "should do something" do
132
+ it "should have the same email" do
133
133
  @account.email.should == @email
134
134
  end
135
135
 
@@ -160,3 +160,28 @@ describe "Set custom domain" do
160
160
 
161
161
  end
162
162
 
163
+
164
+ describe "View account statistics" do
165
+
166
+ before(:each) do
167
+ fake_it_all
168
+ CloudApp.authenticate "testuser@test.com", "password"
169
+ @account = CloudApp::Account.find
170
+ @stats = @account.stats
171
+ end
172
+
173
+ it "should be a Hash object" do
174
+ @stats.should be_a_kind_of Hash
175
+ end
176
+
177
+ it "should have a number of items" do
178
+ @stats[:items].should be_true
179
+ @stats[:items].should be_a_kind_of Integer
180
+ end
181
+
182
+ it "should have a number of views" do
183
+ @stats[:views].should be_true
184
+ @stats[:views].should be_a_kind_of Integer
185
+ end
186
+
187
+ end
@@ -15,51 +15,78 @@ describe CloudApp::Client do
15
15
  auth[:username].should == username
16
16
  end
17
17
 
18
- it "should find an item" do
19
- item = @client.item "2wr4"
20
- item.should be_a_kind_of CloudApp::Item
18
+ it "should find an drop" do
19
+ drop = @client.drop "2wr4"
20
+ drop.should be_a_kind_of CloudApp::Drop
21
21
  end
22
22
 
23
- it "should list all items" do
24
- items = @client.items
25
- items.should be_a_kind_of Array
26
- items.each do |item|
27
- item.should be_a_kind_of CloudApp::Item
23
+ it "should list all drops" do
24
+ drops = @client.drops
25
+ drops.should be_a_kind_of Array
26
+ drops.each do |drop|
27
+ drop.should be_a_kind_of CloudApp::Drop
28
28
  end
29
29
  end
30
30
 
31
- it "should bookmark an item" do
31
+ it "should bookmark an drop" do
32
32
  name = "CloudApp"
33
- item = @client.bookmark "http://getcloudapp.com", name
34
- item.should be_a_kind_of CloudApp::Item
35
- item.name.should == name
33
+ drop = @client.bookmark "http://getcloudapp.com", name
34
+ drop.should be_a_kind_of CloudApp::Drop
35
+ drop.name.should == name
36
+ end
37
+
38
+ it "should bookmark multiple drops" do
39
+ # overwrite the normal fake uri for this spec
40
+ FakeWeb.register_uri :post, 'http://my.cl.ly/items', :response => stub_file(File.join('drop', 'index'))
41
+ bookmarks = [
42
+ { :name => "Authur Dent", :redirect_url => "http://en.wikipedia.org/wiki/Arthur_Dent" },
43
+ { :name => "Ford Prefect", :redirect_url => "http://en.wikipedia.org/wiki/Ford_Prefect_(character)"},
44
+ { :name => "Zaphod Beeblebrox", :redirect_url => "http://en.wikipedia.org/wiki/Zaphod_Beeblebrox" }
45
+ ]
46
+ drops = @client.bookmark bookmarks
47
+ drops.should be_a_kind_of Array
48
+ drops.each do |drop|
49
+ drop.should be_a_kind_of CloudApp::Drop
50
+ end
36
51
  end
37
52
 
38
53
  it "should upload a file" do
39
- item = @client.upload "README.md"
40
- item.should be_a_kind_of CloudApp::Item
41
- item.item_type.should == "image"
54
+ drop = @client.upload "README.md"
55
+ drop.should be_a_kind_of CloudApp::Drop
56
+ drop.item_type.should == "image"
42
57
  end
43
58
 
44
- it "should rename an item" do
59
+ it "should upload a file with specific privacy" do
60
+ # override the upload fakeweb uri
61
+ FakeWeb.register_uri :post, 'http://f.cl.ly', :status => ["303"], :location => "http://my.cl.ly/items/s3?item[private]=true"
62
+ drop = @client.upload "README.md", :private => true
63
+ drop.should be_a_kind_of CloudApp::Drop
64
+ drop.private.should == true
65
+ end
66
+
67
+ it "should rename an drop" do
45
68
  name = "CloudApp"
46
- item = @client.rename "2wr4", name
47
- item.should be_a_kind_of CloudApp::Item
48
- item.name.should == name
69
+ drop = @client.rename "2wr4", name
70
+ drop.should be_a_kind_of CloudApp::Drop
71
+ drop.name.should == name
49
72
  end
50
73
 
51
- it "should set an items privacy" do
52
- item = @client.privacy "2wr4", false
53
- item.should be_a_kind_of CloudApp::Item
54
- item.private.should == false
74
+ it "should set an drops privacy" do
75
+ drop = @client.privacy "2wr4", false
76
+ drop.should be_a_kind_of CloudApp::Drop
77
+ drop.private.should == false
55
78
  end
56
79
 
57
- it "should delete an item" do
58
- item = @client.delete "2wr4"
59
- item.should be_a_kind_of CloudApp::Item
60
- item.deleted_at.should be_a_kind_of Time
80
+ it "should delete an drop" do
81
+ drop = @client.delete "2wr4"
82
+ drop.should be_a_kind_of CloudApp::Drop
83
+ drop.deleted_at.should be_a_kind_of Time
61
84
  end
62
85
 
86
+ it "should recover an drop" do
87
+ drop = @client.recover "2wr4"
88
+ drop.should be_a_kind_of CloudApp::Drop
89
+ drop.deleted_at.should == nil
90
+ end
63
91
 
64
92
  end
65
-
@@ -0,0 +1,258 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe CloudApp::Drop do
4
+
5
+ before(:each) do
6
+ fake_it_all
7
+ @drop = CloudApp::Drop.find "2wr4"
8
+ end
9
+
10
+ it "should be a Drop object" do
11
+ @drop.should be_a_kind_of CloudApp::Drop
12
+ end
13
+
14
+ it "should return a name" do
15
+ @drop.name.should == "CloudApp Logo.png"
16
+ end
17
+
18
+ it "should return an href" do
19
+ @drop.href.should == "http://my.cl.ly/items/1912559"
20
+ end
21
+
22
+ it "should return a privacy boolean" do
23
+ @drop.private.should == false
24
+ end
25
+
26
+ it "should return a url" do
27
+ @drop.url.should == "http://cl.ly/2wr4"
28
+ end
29
+
30
+ it "should return a content url" do
31
+ @drop.content_url.should == "http://cl.ly/2wr4/CloudApp_Logo.png"
32
+ end
33
+
34
+ it "should return a drop type" do
35
+ @drop.item_type.should == "image"
36
+ end
37
+
38
+ it "should return a view counter" do
39
+ @drop.view_counter.should == 42
40
+ end
41
+
42
+ it "should return an icon url" do
43
+ @drop.icon.should == "http://my.cl.ly/images/item_types/image.png"
44
+ end
45
+
46
+ it "should return a remote url" do
47
+ @drop.remote_url == "http://f.cl.ly/items/7c7aea1395c3db0aee18/CloudApp%20Logo.png"
48
+ end
49
+
50
+ it "should not return a redirect url" do
51
+ @drop.redirect_url == nil
52
+ end
53
+
54
+ it "should return timestamps" do
55
+ @drop.created_at.should be_a_kind_of Time
56
+ @drop.updated_at.should be_a_kind_of Time
57
+ @drop.deleted_at.should == nil
58
+ end
59
+
60
+ end
61
+
62
+
63
+ describe "Bookmark link" do
64
+
65
+ before(:each) do
66
+ fake_it_all
67
+ CloudApp.authenticate "testuser@test.com", "password"
68
+ @name = "CloudApp"
69
+ @redirect_url = "http://getcloudapp.com"
70
+ @drop = CloudApp::Drop.create :bookmark, {:name => @name, :redirect_url => @redirect_url}
71
+ end
72
+
73
+ it "should be a Drop object" do
74
+ @drop.should be_a_kind_of CloudApp::Drop
75
+ end
76
+
77
+ it "should return the same name" do
78
+ @drop.name.should == @name
79
+ end
80
+
81
+ it "should return the same redirect_url" do
82
+ @drop.redirect_url.should == @redirect_url
83
+ end
84
+
85
+ end
86
+
87
+
88
+ describe "Bookmark multiple links" do
89
+
90
+ before(:each) do
91
+ fake_it_all
92
+ # overwrite the normal fake uri for this spec
93
+ FakeWeb.register_uri :post, 'http://my.cl.ly/items', :response => stub_file(File.join('drop', 'index'))
94
+ CloudApp.authenticate "testuser@test.com", "password"
95
+ @bookmarks = [
96
+ { :name => "Authur Dent", :redirect_url => "http://en.wikipedia.org/wiki/Arthur_Dent" },
97
+ { :name => "Ford Prefect", :redirect_url => "http://en.wikipedia.org/wiki/Ford_Prefect_(character)"},
98
+ { :name => "Zaphod Beeblebrox", :redirect_url => "http://en.wikipedia.org/wiki/Zaphod_Beeblebrox" }
99
+ ]
100
+ @drops = CloudApp::Drop.create :bookmarks, @bookmarks
101
+ end
102
+
103
+ it "should be an Array" do
104
+ @drops.should be_a_kind_of Array
105
+ end
106
+
107
+ it "should contain Drop objects" do
108
+ @drops.each do |drop|
109
+ drop.should be_a_kind_of CloudApp::Drop
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+
116
+ describe "Change security of an drop" do
117
+
118
+ before(:each) do
119
+ fake_it_all
120
+ CloudApp.authenticate "testuser@test.com", "password"
121
+ @drop = CloudApp::Drop.update "http://my.cl.ly/items/1912565", {:private => false}
122
+ end
123
+
124
+ it "should be an Drop object" do
125
+ @drop.should be_a_kind_of CloudApp::Drop
126
+ end
127
+
128
+ it "should not be private" do
129
+ @drop.private.should == false
130
+ end
131
+
132
+ end
133
+
134
+
135
+
136
+ describe "Delete a drop" do
137
+
138
+ before(:each) do
139
+ fake_it_all
140
+ CloudApp.authenticate "testuser@test.com", "password"
141
+ @drop = CloudApp::Drop.delete "http://my.cl.ly/items/1912565"
142
+ end
143
+
144
+ it "should be an Drop object" do
145
+ @drop.should be_a_kind_of CloudApp::Drop
146
+ end
147
+
148
+ it "should have a deleted_at timestamp" do
149
+ @drop.deleted_at.should be_a_kind_of Time
150
+ end
151
+
152
+ end
153
+
154
+
155
+ describe "Empty trash" do
156
+ end
157
+
158
+
159
+ describe "List drops" do
160
+
161
+ before(:each) do
162
+ fake_it_all
163
+ CloudApp.authenticate "testuser@test.com", "password"
164
+ @drops = CloudApp::Drop.all
165
+ end
166
+
167
+ it "should be an Array" do
168
+ @drops.should be_a_kind_of Array
169
+ end
170
+
171
+ it "should contain Drop objects" do
172
+ @drops.each do |drop|
173
+ drop.should be_a_kind_of CloudApp::Drop
174
+ end
175
+ end
176
+
177
+ end
178
+
179
+
180
+ describe "Recover deleted drop" do
181
+
182
+ before(:each) do
183
+ fake_it_all
184
+ CloudApp.authenticate "testuser@test.com", "password"
185
+ @drop = CloudApp::Drop.recover "http://my.cl.ly/items/1912565"
186
+ end
187
+
188
+ it "should be an Drop object" do
189
+ @drop.should be_a_kind_of CloudApp::Drop
190
+ end
191
+
192
+ it "should not have a deleted_at timestamp" do
193
+ @drop.deleted_at.should == nil
194
+ end
195
+
196
+ end
197
+
198
+
199
+ describe "Rename drop" do
200
+
201
+ before(:each) do
202
+ fake_it_all
203
+ CloudApp.authenticate "testuser@test.com", "password"
204
+ @name = "CloudApp"
205
+ @drop = CloudApp::Drop.update "http://my.cl.ly/items/1912565", {:name => @name}
206
+ end
207
+
208
+ it "should be an Drop object" do
209
+ @drop.should be_a_kind_of CloudApp::Drop
210
+ end
211
+
212
+ it "should be have the same name" do
213
+ @drop.name.should == @name
214
+ end
215
+
216
+ end
217
+
218
+
219
+ describe "Upload file" do
220
+
221
+ before(:each) do
222
+ fake_it_all
223
+ CloudApp.authenticate "testuser@test.com", "password"
224
+ @drop = CloudApp::Drop.create :upload, {:file => "README.md"}
225
+ end
226
+
227
+ it "should be an Drop object" do
228
+ @drop.should be_a_kind_of CloudApp::Drop
229
+ end
230
+
231
+ it "should return a drop type" do
232
+ @drop.item_type.should == "image"
233
+ end
234
+
235
+ end
236
+
237
+
238
+ describe "Upload file with specific privacy" do
239
+
240
+ before(:each) do
241
+ fake_it_all
242
+ # override the upload fakeweb uri
243
+ FakeWeb.register_uri :post, 'http://f.cl.ly', :status => ["303"], :location => "http://my.cl.ly/items/s3?item[private]=true"
244
+ CloudApp.authenticate "testuser@test.com", "password"
245
+ @drop = CloudApp::Drop.create :upload, {:file => "README.md", :private => true}
246
+ end
247
+
248
+ it "should be an Drop object" do
249
+ @drop.should be_a_kind_of CloudApp::Drop
250
+ end
251
+
252
+ it "should return as private" do
253
+ @drop.private.should == true
254
+ end
255
+
256
+ end
257
+
258
+