cloudapp 2.0.0.beta.3 → 2.0.0.beta.4
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/cloudapp.gemspec +3 -16
- data/lib/cloudapp/drop.rb +9 -4
- data/lib/cloudapp/drop_collection.rb +18 -3
- data/lib/cloudapp/service.rb +31 -9
- data/lib/cloudapp.rb +1 -3
- data/spec/cassettes/account_token.yml +88 -0
- data/spec/cassettes/create_bookmark.yml +75 -198
- data/spec/cassettes/create_bookmark_with_name.yml +76 -209
- data/spec/cassettes/create_bookmark_with_privacy.yml +76 -220
- data/spec/cassettes/list_drops.yml +49 -101
- data/spec/cassettes/list_drops_with_bad_token.yml +25 -37
- data/spec/cassettes/list_drops_with_filter.yml +73 -153
- data/spec/cassettes/list_drops_with_limit.yml +73 -155
- data/spec/cassettes/purge_drops.yml +259 -896
- data/spec/cassettes/setup_drops.yml +318 -666
- data/spec/cassettes/token_for_account.yml +53 -92
- data/spec/cassettes/token_for_account_with_bad_credentials.yml +51 -80
- data/spec/cassettes/upload_file.yml +119 -313
- data/spec/cassettes/upload_file_with_name.yml +121 -327
- data/spec/cassettes/upload_file_with_privacy.yml +120 -338
- data/spec/cassettes/view_drop.yml +26 -54
- data/spec/cloudapp/drop_collection_spec.rb +86 -22
- data/spec/cloudapp/drop_spec.rb +24 -1
- data/spec/cloudapp/service_spec.rb +183 -205
- data/spec/integration_spec.rb +43 -75
- data/spec/support/vcr.rb +1 -1
- metadata +3 -16
- data/lib/cloudapp/account.rb +0 -111
- data/lib/cloudapp/token.rb +0 -27
- data/spec/cassettes/delete_drop.yml +0 -383
- data/spec/cassettes/list_drops_with_href.yml +0 -287
- data/spec/cassettes/list_drops_with_href_and_filter.yml +0 -287
- data/spec/cassettes/list_drops_with_href_and_limit.yml +0 -287
- data/spec/cassettes/list_drops_with_nil_href.yml +0 -139
- data/spec/cassettes/recover_drop.yml +0 -628
- data/spec/cassettes/rename_drop.yml +0 -367
- data/spec/cassettes/trash_drop.yml +0 -478
- data/spec/cassettes/update_drop_bookmark_url.yml +0 -379
- data/spec/cassettes/update_file.yml +0 -573
- data/spec/cloudapp/account_spec.rb +0 -166
- data/spec/cloudapp/token_spec.rb +0 -33
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.getcloudapp.com/drops/
|
5
|
+
uri: https://api.getcloudapp.com/drops/21399180
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,62 +12,34 @@ http_interactions:
|
|
12
12
|
Accept:
|
13
13
|
- application/json, text/x-yaml, application/xml, application/xhtml+xml, text/html,
|
14
14
|
text/plain
|
15
|
+
Accept-Encoding:
|
16
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
17
|
+
User-Agent:
|
18
|
+
- Ruby
|
15
19
|
response:
|
16
20
|
status:
|
17
21
|
code: 200
|
18
|
-
message:
|
19
|
-
T0s=
|
22
|
+
message: OK
|
20
23
|
headers:
|
21
|
-
|
22
|
-
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
-
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
!binary "WC1VYS1Db21wYXRpYmxl":
|
38
|
-
- !binary |-
|
39
|
-
SUU9RWRnZSxjaHJvbWU9MQ==
|
40
|
-
!binary "VHJhbnNmZXItRW5jb2Rpbmc=":
|
41
|
-
- !binary |-
|
42
|
-
Y2h1bmtlZA==
|
43
|
-
!binary "Q29ubmVjdGlvbg==":
|
44
|
-
- !binary |-
|
45
|
-
a2VlcC1hbGl2ZQ==
|
24
|
+
Cache-Control:
|
25
|
+
- max-age=0, private, must-revalidate
|
26
|
+
Content-Type:
|
27
|
+
- application/vnd.collection+json; charset=utf-8
|
28
|
+
Etag:
|
29
|
+
- ! '"bb369d9d7751f58571e26e70ce265e12"'
|
30
|
+
Server:
|
31
|
+
- thin 1.4.1 codename Chromeo
|
32
|
+
X-Runtime:
|
33
|
+
- '0.027599'
|
34
|
+
X-Ua-Compatible:
|
35
|
+
- IE=Edge,chrome=1
|
36
|
+
Transfer-Encoding:
|
37
|
+
- chunked
|
38
|
+
Connection:
|
39
|
+
- keep-alive
|
46
40
|
body:
|
47
|
-
encoding: ASCII
|
48
|
-
string: !
|
49
|
-
eyJjb2xsZWN0aW9uIjp7InZlcnNpb24iOiIxLjAiLCJocmVmIjoiaHR0cHM6
|
50
|
-
Ly9hcGkuZ2V0Y2xvdWRhcHAuY29tL2Ryb3BzIiwibGlua3MiOlt7InJlbCI6
|
51
|
-
ImRyb3BzLXN0cmVhbSIsImhyZWYiOiJodHRwczovL2FwaS5nZXRjbG91ZGFw
|
52
|
-
cC5jb20vZHJvcHMvc3RyZWFtIn1dLCJxdWVyaWVzIjpbeyJocmVmIjoiaHR0
|
53
|
-
cHM6Ly9hcGkuZ2V0Y2xvdWRhcHAuY29tL2Ryb3BzIiwicmVsIjoiZHJvcHMt
|
54
|
-
bGlzdCIsImRhdGEiOlt7Im5hbWUiOiJmaWx0ZXIiLCJ2YWx1ZSI6ImFjdGl2
|
55
|
-
ZSJ9LHsibmFtZSI6ImxpbWl0IiwidmFsdWUiOjIwfV19XSwidGVtcGxhdGUi
|
56
|
-
OnsiZGF0YSI6W3sibmFtZSI6Im5hbWUiLCJ2YWx1ZSI6bnVsbH0seyJuYW1l
|
57
|
-
IjoicHJpdmF0ZSIsInZhbHVlIjp0cnVlfSx7Im5hbWUiOiJ0cmFzaCIsInZh
|
58
|
-
bHVlIjpmYWxzZX0seyJuYW1lIjoiYm9va21hcmtfdXJsIiwidmFsdWUiOm51
|
59
|
-
bGx9LHsibmFtZSI6ImZpbGVfc2l6ZSIsInZhbHVlIjpudWxsfV19LCJpdGVt
|
60
|
-
cyI6W3siaHJlZiI6Imh0dHBzOi8vYXBpLmdldGNsb3VkYXBwLmNvbS9kcm9w
|
61
|
-
cy8yMTE4NTg5MCIsImxpbmtzIjpbeyJyZWwiOiJjb2xsZWN0aW9uIiwiaHJl
|
62
|
-
ZiI6Imh0dHBzOi8vYXBpLmdldGNsb3VkYXBwLmNvbS9kcm9wcyJ9LHsicmVs
|
63
|
-
IjoiY2Fub25pY2FsIiwiaHJlZiI6Imh0dHA6Ly9jbC5seS9JcDg1In0seyJy
|
64
|
-
ZWwiOiJpY29uIiwiaHJlZiI6Imh0dHBzOi8vZDl5YWMxMzZ1MDQ4ei5jbG91
|
65
|
-
ZGZyb250Lm5ldC9pbWFnZXMvdGh1bWJuYWlscy9ib29rbWFyay5wbmcifV0s
|
66
|
-
ImRhdGEiOlt7Im5hbWUiOiJpZCIsInZhbHVlIjoyMTE4NTg5MH0seyJuYW1l
|
67
|
-
IjoibmFtZSIsInZhbHVlIjoiaHR0cDovL2NsLmx5In0seyJuYW1lIjoicHJp
|
68
|
-
dmF0ZSIsInZhbHVlIjpmYWxzZX0seyJuYW1lIjoidHJhc2giLCJ2YWx1ZSI6
|
69
|
-
ZmFsc2V9LHsibmFtZSI6InZpZXdzIiwidmFsdWUiOjB9LHsibmFtZSI6ImNy
|
70
|
-
ZWF0ZWQiLCJ2YWx1ZSI6IjIwMTItMDgtMTdUMTg6MTE6MzlaIn1dfV19fQ==
|
41
|
+
encoding: US-ASCII
|
42
|
+
string: ! '{"collection":{"version":"1.0","href":"https://api.getcloudapp.com/drops","links":[{"rel":"drops-stream","href":"https://api.getcloudapp.com/drops/stream"}],"queries":[{"href":"https://api.getcloudapp.com/drops","rel":"drops-list","data":[{"name":"filter","value":"active"},{"name":"limit","value":20}]}],"template":{"data":[{"name":"name","value":null},{"name":"private","value":true},{"name":"trash","value":false},{"name":"bookmark_url","value":null},{"name":"file_size","value":null}]},"items":[{"href":"https://api.getcloudapp.com/drops/21399180","links":[{"rel":"collection","href":"https://api.getcloudapp.com/drops"},{"rel":"canonical","href":"http://cl.ly/IzhX"},{"rel":"icon","href":"https://d9yac136u048z.cloudfront.net/images/thumbnails/bookmark.png"}],"data":[{"name":"id","value":21399180},{"name":"name","value":"http://cl.ly"},{"name":"private","value":false},{"name":"trash","value":false},{"name":"views","value":0},{"name":"created","value":"2012-08-24T20:43:24Z"}]}]}}'
|
71
43
|
http_version:
|
72
|
-
recorded_at: Fri,
|
73
|
-
recorded_with: VCR 2.0.
|
44
|
+
recorded_at: Fri, 24 Aug 2012 20:43:33 GMT
|
45
|
+
recorded_with: VCR 2.0.1
|
@@ -4,12 +4,26 @@ require 'ostruct'
|
|
4
4
|
require 'cloudapp/drop_collection'
|
5
5
|
|
6
6
|
describe CloudApp::DropCollection do
|
7
|
-
let(:representation) { stub :representation, unauthorized?:
|
8
|
-
items:
|
9
|
-
let(:
|
7
|
+
let(:representation) { stub :representation, unauthorized?: false,
|
8
|
+
items: items }
|
9
|
+
let(:service) { stub :service }
|
10
10
|
let(:items) {[ stub(:item1), stub(:item2) ]}
|
11
|
-
let(:drop_class) { stub(:drop_class, new:
|
12
|
-
subject { CloudApp::DropCollection.new representation, drop_class }
|
11
|
+
let(:drop_class) { stub(:drop_class, new: :drop) }
|
12
|
+
subject { CloudApp::DropCollection.new representation, service, drop_class }
|
13
|
+
|
14
|
+
describe 'collection' do
|
15
|
+
it 'is a collection of drops' do
|
16
|
+
subject.size.should eq(2)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'decodes each drop' do
|
20
|
+
items.each do |drop|
|
21
|
+
drop_class.should_receive(:new).once.
|
22
|
+
with(drop, kind_of(CloudApp::DropCollection))
|
23
|
+
end
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
end
|
13
27
|
|
14
28
|
describe '#authorized?' do
|
15
29
|
let(:authorized) { stub :authorized }
|
@@ -22,41 +36,91 @@ describe CloudApp::DropCollection do
|
|
22
36
|
|
23
37
|
describe '#unauthorized?' do
|
24
38
|
let(:unauthorized) { stub :unauthorized }
|
39
|
+
before do representation.stub(unauthorized?: unauthorized) end
|
25
40
|
|
26
41
|
it 'delegates to representation' do
|
27
42
|
subject.unauthorized?.should eq(unauthorized)
|
28
43
|
end
|
29
44
|
end
|
30
45
|
|
31
|
-
describe '#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
46
|
+
describe '#follow' do
|
47
|
+
let(:link_representation) {
|
48
|
+
stub :link_representation, unauthorized?: false,
|
49
|
+
items: []
|
50
|
+
}
|
51
|
+
subject {
|
52
|
+
CloudApp::DropCollection.
|
53
|
+
new(representation, service, drop_class).
|
54
|
+
follow('yes')
|
55
|
+
}
|
56
|
+
|
57
|
+
before do
|
58
|
+
link = stub :link
|
59
|
+
link.should_receive(:follow).once.and_return(link_representation)
|
60
|
+
representation.should_receive(:link).once.and_return(link)
|
36
61
|
end
|
62
|
+
|
63
|
+
it { subject.should be_a(CloudApp::DropCollection) }
|
64
|
+
its(:representation) { should eq(link_representation) }
|
65
|
+
its(:drop_class) { should eq(drop_class) }
|
37
66
|
end
|
38
67
|
|
39
|
-
describe '#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
68
|
+
describe '#has_link?' do
|
69
|
+
context 'with link' do
|
70
|
+
before do
|
71
|
+
representation.should_receive(:link).
|
72
|
+
once.
|
73
|
+
with('yes').
|
74
|
+
and_return(stub(:link))
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns false' do
|
78
|
+
subject.has_link?('yes').should eq(true)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'without link' do
|
83
|
+
before do
|
84
|
+
representation.should_receive(:link).
|
85
|
+
once.
|
86
|
+
with('no').
|
87
|
+
and_yield
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns true' do
|
91
|
+
subject.has_link?('no').should eq(false)
|
92
|
+
end
|
44
93
|
end
|
45
94
|
end
|
46
95
|
|
47
|
-
|
48
|
-
|
96
|
+
describe '#trash' do
|
97
|
+
it 'trashes the given drop' do
|
98
|
+
href = stub :href
|
99
|
+
service.should_receive(:trash_drop).once.with(href)
|
100
|
+
subject.trash stub(:drop, href: href)
|
101
|
+
end
|
49
102
|
end
|
50
103
|
|
51
|
-
|
52
|
-
|
53
|
-
|
104
|
+
describe '#recover' do
|
105
|
+
it 'recovers the given drop' do
|
106
|
+
href = stub :href
|
107
|
+
service.should_receive(:recover_drop).once.with(href)
|
108
|
+
subject.recover stub(:drop, href: href)
|
54
109
|
end
|
55
|
-
subject
|
56
110
|
end
|
57
111
|
|
112
|
+
describe '#delete' do
|
113
|
+
it 'deletes the given drop' do
|
114
|
+
href = stub :href
|
115
|
+
service.should_receive(:delete_drop).once.with(href)
|
116
|
+
subject.delete stub(:drop, href: href)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#delete'
|
121
|
+
|
58
122
|
context 'unauthorized' do
|
59
|
-
|
123
|
+
before do representation.stub(unauthorized?: true) end
|
60
124
|
|
61
125
|
it { should be_empty }
|
62
126
|
end
|
data/spec/cloudapp/drop_spec.rb
CHANGED
@@ -7,8 +7,10 @@ describe CloudApp::Drop do
|
|
7
7
|
let(:href) { stub :href }
|
8
8
|
let(:links) { [] }
|
9
9
|
let(:data) { {} }
|
10
|
+
let(:collection) { stub :collection }
|
10
11
|
subject {
|
11
|
-
CloudApp::Drop.new stub(:drop, href: href, links: links, data: data)
|
12
|
+
CloudApp::Drop.new stub(:drop, href: href, links: links, data: data),
|
13
|
+
collection
|
12
14
|
}
|
13
15
|
|
14
16
|
its(:href) { should eq(href) }
|
@@ -116,4 +118,25 @@ describe CloudApp::Drop do
|
|
116
118
|
its(:download_url) { should be_nil }
|
117
119
|
end
|
118
120
|
end
|
121
|
+
|
122
|
+
describe '#trash' do
|
123
|
+
it 'trashes itself' do
|
124
|
+
collection.should_receive(:trash).once.with(subject)
|
125
|
+
subject.trash
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#recover' do
|
130
|
+
it 'recovers itself' do
|
131
|
+
collection.should_receive(:recover).once.with(subject)
|
132
|
+
subject.recover
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe '#delete' do
|
137
|
+
it 'deletes itself' do
|
138
|
+
collection.should_receive(:delete).once.with(subject)
|
139
|
+
subject.delete
|
140
|
+
end
|
141
|
+
end
|
119
142
|
end
|