browse-everything 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 730808dd49026de8e75b8344369e54ccd437b397
4
- data.tar.gz: fd60f9a6709d2dae71fedb6b6f1d5a62a0174219
3
+ metadata.gz: 217e127add171d887e8e372ba7505f20bfd3c862
4
+ data.tar.gz: f6de9170c170e8df631283bf3817259285798508
5
5
  SHA512:
6
- metadata.gz: 1d5c2642e90c7dbd4babdaff36ea7408418813e00467c2a321abae41fb963bbec09aede9dfb111d7b082f7ed5781f63a81bf3f78b3088f2303ce1fe18c828347
7
- data.tar.gz: 976c6e152a9712df3bf074a6a84df9a1d7321fe111386ed6f7c6235f8a5bde2056606b1e66ce8a5a6337dd59b16e1bc8e03301858c5124906f4388396947c919
6
+ metadata.gz: d9cfc43d9f3a117f5e2da42ffd6af90e92897c193c07559da01f7a3789c85212298d74da49fbeeb3fd5c461962cf8f246548d03b60f9a64f31ffffcf76ce1bc6
7
+ data.tar.gz: ad1002469c1cddbd63c268f83ef083bcf56d0a1b8c5a6a6177626fe02e83f534eaafbf870223da4b7a8f28e649ec0b072ef34202fccc3856f6f3cad192dde3d1
data/.rubocop.yml CHANGED
@@ -13,7 +13,7 @@ Rails:
13
13
 
14
14
  Metrics/ClassLength:
15
15
  Max: 130
16
-
16
+
17
17
  # Configuration parameters: AllowURI, URISchemes.
18
18
  Metrics/LineLength:
19
19
  Max: 400
@@ -27,6 +27,16 @@ RSpec/FilePath:
27
27
  RSpec/LeadingSubject:
28
28
  Enabled: false
29
29
 
30
+ RSpec/ExampleLength:
31
+ Exclude:
32
+ - 'spec/unit/dropbox_spec.rb'
33
+ - 'spec/features/select_files_spec.rb'
34
+ - 'spec/javascripts/jasmine_spec.rb'
35
+
36
+ RSpec/MultipleExpectations:
37
+ Exclude:
38
+ - 'spec/unit/dropbox_spec.rb'
39
+
30
40
  Style/NumericLiterals:
31
41
  MinDigits: 7
32
42
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'rails', '>= 3.1'
22
22
  spec.add_dependency 'addressable', '~> 2.5'
23
23
  spec.add_dependency 'google_drive'
24
- spec.add_dependency 'dropbox-sdk', '>= 1.6.2'
24
+ spec.add_dependency 'dropbox_api', '>= 0.1.10'
25
25
  spec.add_dependency 'ruby-box'
26
26
  spec.add_dependency 'sass-rails'
27
27
  spec.add_dependency 'bootstrap-sass', '~> 3.2'
@@ -1,63 +1,99 @@
1
- require 'dropbox_sdk'
1
+ require 'dropbox_api'
2
2
 
3
3
  module BrowseEverything
4
4
  module Driver
5
5
  class Dropbox < Base
6
- CONFIG_KEYS = [:app_key, :app_secret].freeze
6
+ class FileEntryFactory
7
+ def self.build(metadata:, key:)
8
+ factory_klass = klass_for metadata
9
+ factory_klass.build(metadata: metadata, key: key)
10
+ end
11
+
12
+ class << self
13
+ private def klass_for(metadata)
14
+ case metadata
15
+ when DropboxApi::Metadata::File
16
+ FileFactory
17
+ else
18
+ ResourceFactory
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ class ResourceFactory
25
+ def self.build(metadata:, key:)
26
+ path = metadata.path_display
27
+ BrowseEverything::FileEntry.new(
28
+ path,
29
+ [key, path].join(':'),
30
+ File.basename(path),
31
+ nil,
32
+ nil,
33
+ true
34
+ )
35
+ end
36
+ end
37
+
38
+ class FileFactory
39
+ def self.build(metadata:, key:)
40
+ path = metadata.path_display
41
+ BrowseEverything::FileEntry.new(
42
+ path,
43
+ [key, path].join(':'),
44
+ File.basename(path),
45
+ metadata.size,
46
+ metadata.client_modified,
47
+ false
48
+ )
49
+ end
50
+ end
7
51
 
8
52
  def icon
9
53
  'dropbox'
10
54
  end
11
55
 
12
56
  def validate_config
13
- return if CONFIG_KEYS.all? { |key| config[key].present? }
14
- raise BrowseEverything::InitializationError, "Dropbox driver requires #{CONFIG_KEYS.inspect}"
57
+ raise BrowseEverything::InitializationError, 'Dropbox driver requires a :client_id argument' unless config[:client_id]
58
+ raise BrowseEverything::InitializationError, 'Dropbox driver requires a :client_secret argument' unless config[:client_secret]
15
59
  end
16
60
 
17
- # @return [Array<BrowseEverything::FileEntry>]
18
61
  def contents(path = '')
19
- path.sub!(%r{ /^[\/.]+/}, '')
20
- result = add_directory_entry(path)
21
- result += client.metadata(path)['contents'].collect { |info| make_file_entry(info) }
22
- result
62
+ result = client.list_folder(path)
63
+ result.entries.map { |entry| FileEntryFactory.build(metadata: entry, key: key) }
23
64
  end
24
65
 
25
- def add_directory_entry(path)
26
- return [] if path.empty?
27
- [BrowseEverything::FileEntry.new(
28
- Pathname(path).join('..'),
29
- '', '..', 0, Time.zone.now, true
30
- )]
66
+ def details(path)
67
+ metadata = client.get_metadata(path)
68
+ FileEntryFactory.build(metadata: metadata, key: key)
31
69
  end
32
70
 
33
- def make_file_entry(info)
34
- path = info['path']
35
- BrowseEverything::FileEntry.new(
36
- path,
37
- [key, path].join(':'),
38
- File.basename(path),
39
- info['bytes'],
40
- Time.zone.parse(info['modified']),
41
- info['is_dir']
42
- )
71
+ def download(path)
72
+ temp_file = Tempfile.open(File.basename(path), encoding: 'ascii-8bit')
73
+ client.download(path) do |chunk|
74
+ temp_file.write chunk
75
+ end
76
+ temp_file.close
77
+ temp_file
43
78
  end
44
79
 
45
- def link_for(path)
46
- [client.media(path)['url'], { expires: 4.hours.from_now, file_name: File.basename(path), file_size: client.metadata(path)['bytes'].to_i }]
80
+ def uri_for(path)
81
+ temp_file = download(path)
82
+ uri = ::Addressable::URI.new(scheme: 'file', path: temp_file.path)
83
+ uri.to_s
47
84
  end
48
85
 
49
- def details(path)
50
- contents(path).first
86
+ def link_for(path)
87
+ [uri_for(path), {}]
51
88
  end
52
89
 
53
90
  def auth_link
54
- [auth_flow.start('dropbox'), @csrf]
91
+ authenticator.authorize_url
55
92
  end
56
93
 
57
- def connect(params, data)
58
- @csrf = data
59
- @token, _user, _state = auth_flow.finish(params)
60
- @token
94
+ def connect(params, _data)
95
+ auth_bearer = authenticator.get_token(params[:code])
96
+ self.token = auth_bearer.token
61
97
  end
62
98
 
63
99
  def authorized?
@@ -66,13 +102,12 @@ module BrowseEverything
66
102
 
67
103
  private
68
104
 
69
- def auth_flow
70
- @csrf ||= {}
71
- DropboxOAuth2Flow.new(config[:app_key], config[:app_secret], callback.to_s, @csrf, 'token')
105
+ def authenticator
106
+ @authenticator ||= DropboxApi::Authenticator.new(config[:client_id], config[:client_secret])
72
107
  end
73
108
 
74
109
  def client
75
- DropboxClient.new(token)
110
+ DropboxApi::Client.new(token)
76
111
  end
77
112
  end
78
113
  end
@@ -84,7 +84,7 @@ module BrowseEverything
84
84
  File.size(url.path)
85
85
  when /https?/
86
86
  response = HTTParty.head(parsed_spec[:url].to_s, headers: parsed_spec[:headers])
87
- response.content_length
87
+ (response.content_length || parsed_spec[:file_size]).to_i
88
88
  else
89
89
  raise URI::BadURIError, "Unknown URI scheme: #{url.scheme}"
90
90
  end
@@ -1,3 +1,3 @@
1
1
  module BrowseEverything
2
- VERSION = '0.15.0'.freeze
2
+ VERSION = '0.15.1'.freeze
3
3
  end
@@ -2,391 +2,281 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://api.dropbox.com/1/oauth2/token
5
+ uri: https://api.dropboxapi.com/oauth2/token
6
6
  body:
7
7
  encoding: UTF-8
8
- string: grant_type=authorization_code&code=FakeDropboxAuthorizationCodeABCDEFG&redirect_uri=http%3A%2F%2Fbrowse.example.edu%2Fbrowse%2Fconnect
8
+ string: client_id=id&client_secret=secret&code=code&grant_type=authorization_code
9
9
  headers:
10
- Accept: ! '*/*'
11
- User-Agent: OfficialDropboxRubySDK/1.6.1
12
- Content-Type: application/x-www-form-urlencoded
13
- Connection: close
14
- Host: api.dropbox.com
15
- Content-Length: '140'
10
+ User-Agent:
11
+ - Faraday v0.12.2
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
16
18
  response:
17
19
  status:
18
- code: '200'
20
+ code: 200
19
21
  message: OK
20
22
  headers:
21
- Server: nginx
22
- Date: Fri, 20 Sep 2013 15:38:46 GMT
23
- Content-Type: text/javascript
24
- Transfer-Encoding: chunked
25
- Connection: close
26
- x-server-response-time: '92'
27
- x-dropbox-request-id: adb756ec7f02c3a142c9d43c479c2033
28
- pragma: no-cache
29
- cache-control: no-cache
30
- x-dropbox-http-protocol: None
31
- x-frame-options: SAMEORIGIN
32
- X-RequestId: 9a70a92424860e2700a2f741b4d0dc6f
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 01 Nov 2017 15:23:50 GMT
27
+ Content-Type:
28
+ - text/javascript
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Vary:
34
+ - Accept-Encoding
35
+ Cache-Control:
36
+ - no-cache
37
+ Pragma:
38
+ - no-cache
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ X-Dropbox-Request-Id:
42
+ - f2f4174c641db0b51f5d82987fefca9b
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Server-Response-Time:
46
+ - '380'
33
47
  body:
34
- encoding: UTF-8
35
- string: ! '{"access_token": "FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321",
36
- "token_type": "bearer", "uid": "1234567"}'
37
- http_version: '1.1'
38
- recorded_at: Fri, 20 Sep 2013 15:38:46 GMT
39
- - request:
40
- method: get
41
- uri: https://api.dropbox.com/1/metadata/auto/?file_limit=25000&include_deleted=false&include_media_info=false&list=true
42
- body:
43
- encoding: UTF-8
44
- string: ''
45
- headers:
46
- Accept: ! '*/*'
47
- User-Agent: OfficialDropboxRubySDK/1.6.1
48
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
49
- Connection: close
50
- Host: api.dropbox.com
51
- response:
52
- status:
53
- code: '200'
54
- message: OK
55
- headers:
56
- Server: nginx
57
- Date: Fri, 20 Sep 2013 15:38:48 GMT
58
- Content-Type: text/javascript
59
- Transfer-Encoding: chunked
60
- Connection: close
61
- set-cookie: ! 'gvc=MjMzNzg4MzEzNTQ2Mzk1MzQ0NjcxNzY2ODI2MDkzODUzNzI5NTYw; expires=Wed,
62
- 19 Sep 2018 15:38:48
63
-
64
- GMT; Path=/; httponly'
65
- x-server-response-time: '50'
66
- x-dropbox-request-id: da19c8c6ca44a67e6c2db3f0254058d1
67
- pragma: no-cache
68
- cache-control: no-cache
69
- x-dropbox-http-protocol: None
70
- x-frame-options: SAMEORIGIN
71
- X-RequestId: 057f2caf7291c8f9684a0626480afb30
72
- body:
73
- encoding: UTF-8
74
- string: ! '{ "hash": "60657d5728ee9c36971c0c8269a1c5e8", "thumb_exists": false, "bytes":
75
- 0, "path": "/", "is_dir": true, "size": "0 bytes", "root": "dropbox", "contents":
76
- [ { "revision": 8743, "rev": "222700cbb190", "thumb_exists": false, "bytes": 0,
77
- "modified": "Sun, 09 Dec 2012 20:30:45 +0000", "path": "/Apps", "is_dir": true,
78
- "icon": "folder", "root": "dropbox", "size": "0 bytes" }, { "revision": 6944, "rev":
79
- "1b2000cbb190", "thumb_exists": false, "bytes": 0, "modified": "Sun, 25 Mar 2012
80
- 00:36:39 +0000", "path": "/Books", "is_dir": true, "icon": "folder", "root": "dropbox",
81
- "size": "0 bytes" }, { "revision": 14, "rev": "e00cbb190", "thumb_exists": false,
82
- "bytes": 0, "modified": "Mon, 28 Jun 2010 16:53:48 +0000", "path": "/Documents",
83
- "is_dir": true, "icon": "folder", "root": "dropbox", "size": "0 bytes" }, { "revision":
84
- 9, "rev": "900cbb190", "thumb_exists": false, "bytes": 127748, "modified": "Mon,
85
- 28 Jun 2010 16:49:18 +0000", "client_mtime": "Mon, 28 Jun 2010 16:49:19 +0000",
86
- "path": "/Getting Started.pdf", "is_dir": false, "icon": "page_white_acrobat", "root":
87
- "dropbox", "mime_type": "application/pdf", "size": "124.8 KB" }, { "revision": 1975,
88
- "rev": "7b700cbb190", "thumb_exists": false, "bytes": 208218, "modified": "Mon,
89
- 28 Jun 2010 17:28:47 +0000", "client_mtime": "Mon, 28 Jun 2010 17:28:47 +0000",
90
- "path": "/iPad intro.pdf", "is_dir": false, "icon": "page_white_acrobat", "root":
91
- "dropbox", "mime_type": "application/pdf", "size": "203.3 KB" }, { "revision": 1973,
92
- "rev": "7b500cbb190", "thumb_exists": false, "bytes": 315187, "modified": "Mon,
93
- 28 Jun 2010 17:27:11 +0000", "client_mtime": "Mon, 28 Jun 2010 17:27:11 +0000",
94
- "path": "/iPhone intro.pdf", "is_dir": false, "icon": "page_white_acrobat", "root":
95
- "dropbox", "mime_type": "application/pdf", "size": "307.8 KB" }, { "revision": 2636,
96
- "rev": "a4c00cbb190", "thumb_exists": false, "bytes": 0, "modified": "Thu, 23 Sep
97
- 2010 06:30:15 +0000", "path": "/Writer", "is_dir": true, "icon": "folder", "root":
98
- "dropbox", "size": "0 bytes" } ], "icon": "folder" }'
99
- http_version: '1.1'
100
- recorded_at: Fri, 20 Sep 2013 15:38:48 GMT
101
- - request:
102
- method: get
103
- uri: https://api.dropbox.com/1/metadata/auto/Writer?file_limit=25000&include_deleted=false&include_media_info=false&list=true
104
- body:
105
- encoding: UTF-8
106
- string: ''
107
- headers:
108
- Accept: ! '*/*'
109
- User-Agent: OfficialDropboxRubySDK/1.6.1
110
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
111
- Connection: close
112
- Host: api.dropbox.com
113
- response:
114
- status:
115
- code: '200'
116
- message: OK
117
- headers:
118
- Server: nginx
119
- Date: Fri, 20 Sep 2013 15:38:55 GMT
120
- Content-Type: text/javascript
121
- Transfer-Encoding: chunked
122
- Connection: close
123
- set-cookie: ! 'gvc=Njg4MTEzOTAzNjIxMzA3Mzg0Nzk4ODMwMjc3ODE5Mjk1OTIyMjY%3D; expires=Wed,
124
- 19 Sep 2018 15:38:55
125
-
126
- GMT; Path=/; httponly'
127
- x-server-response-time: '64'
128
- x-dropbox-request-id: 349e4a2b10c59d22f4e686ddbd608b69
129
- pragma: no-cache
130
- cache-control: no-cache
131
- x-dropbox-http-protocol: None
132
- x-frame-options: SAMEORIGIN
133
- X-RequestId: 83bc363934d5a5457cbcbd0fab8b4cfb
134
- body:
135
- encoding: UTF-8
136
- string: ! '{ "hash": "c4a067b0bfef9feefca072bb14d9be93", "revision": 2636, "rev": "a4c00cbb190",
137
- "thumb_exists": false, "bytes": 0, "modified": "Thu, 23 Sep 2010 06:30:15 +0000",
138
- "path": "/Writer", "is_dir": true, "icon": "folder", "root": "dropbox", "contents":
139
- [ { "revision": 4011, "rev": "fab00cbb190", "thumb_exists": false, "bytes": 11642,
140
- "modified": "Sat, 09 Apr 2011 18:54:55 +0000", "client_mtime": "Sat, 09 Apr 2011
141
- 18:54:55 +0000", "path": "/Writer/About Writer.txt", "is_dir": false, "icon": "page_white_text",
142
- "root": "dropbox", "mime_type": "text/plain", "size": "11.4 KB" }, { "revision":
143
- 2754, "rev": "ac200cbb190", "thumb_exists": false, "bytes": 988, "modified": "Thu,
144
- 14 Oct 2010 08:32:20 +0000", "client_mtime": "Thu, 14 Oct 2010 08:32:20 +0000",
145
- "path": "/Writer/Markdown Test.txt", "is_dir": false, "icon": "page_white_text",
146
- "root": "dropbox", "mime_type": "text/plain", "size": "988 bytes" }, { "revision":
147
- 4009, "rev": "fa900cbb190", "thumb_exists": false, "bytes": 20904, "modified": "Sat,
148
- 09 Apr 2011 18:54:54 +0000", "client_mtime": "Sat, 09 Apr 2011 18:54:54 +0000",
149
- "path": "/Writer/Writer FAQ.txt", "is_dir": false, "icon": "page_white_text", "root":
150
- "dropbox", "mime_type": "text/plain", "size": "20.4 KB" } ], "size": "0 bytes" }'
151
- http_version: '1.1'
152
- recorded_at: Fri, 20 Sep 2013 15:38:55 GMT
153
- - request:
154
- method: get
155
- uri: https://api.dropbox.com/1/media/auto/Writer/Writer%20FAQ.txt?
156
- body:
157
- encoding: UTF-8
158
- string: ''
159
- headers:
160
- Accept: ! '*/*'
161
- User-Agent: OfficialDropboxRubySDK/1.6.1
162
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
163
- Connection: close
164
- Host: api.dropbox.com
165
- response:
166
- status:
167
- code: '200'
168
- message: OK
169
- headers:
170
- Server: nginx
171
- Date: Fri, 20 Sep 2013 15:39:01 GMT
172
- Content-Type: text/javascript
173
- Transfer-Encoding: chunked
174
- Connection: close
175
- set-cookie: ! 'gvc=MjEyNTM5NjUyNDAyMDIwODUzNTU0MTY0NzA0ODU4MzczNTU0NDI%3D; expires=Wed,
176
- 19 Sep 2018 15:39:01
177
-
178
- GMT; Path=/; httponly'
179
- x-server-response-time: '68'
180
- x-dropbox-request-id: d8dbc2e2080168d6e34d85165aa69c0e
181
- pragma: no-cache
182
- cache-control: no-cache
183
- x-dropbox-http-protocol: None
184
- x-frame-options: SAMEORIGIN
185
- X-RequestId: e03a6c0ded5f7088ba59ecd9e97234a6
186
- body:
187
- encoding: UTF-8
188
- string: ! '{"url": "https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Writer%20FAQ.txt",
189
- "expires": "Fri, 20 Sep 2013 19:39:01 +0000"}'
190
- http_version: '1.1'
191
- recorded_at: Fri, 20 Sep 2013 15:39:01 GMT
192
- - request:
193
- method: get
194
- uri: https://api.dropbox.com/1/media/auto/Writer/Writer%20FAQ.txt
195
- body:
196
- encoding: UTF-8
197
- string: ''
198
- headers:
199
- Accept: ! '*/*'
200
- User-Agent: OfficialDropboxRubySDK/1.6.1
201
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
202
- Connection: close
203
- Host: api.dropbox.com
204
- response:
205
- status:
206
- code: '200'
207
- message: OK
208
- headers:
209
- Server: nginx
210
- Date: Fri, 20 Sep 2013 15:39:01 GMT
211
- Content-Type: text/javascript
212
- Transfer-Encoding: chunked
213
- Connection: close
214
- set-cookie: ! 'gvc=MjEyNTM5NjUyNDAyMDIwODUzNTU0MTY0NzA0ODU4MzczNTU0NDI%3D; expires=Wed,
215
- 19 Sep 2018 15:39:01
216
-
217
- GMT; Path=/; httponly'
218
- x-server-response-time: '68'
219
- x-dropbox-request-id: d8dbc2e2080168d6e34d85165aa69c0e
220
- pragma: no-cache
221
- cache-control: no-cache
222
- x-dropbox-http-protocol: None
223
- x-frame-options: SAMEORIGIN
224
- X-RequestId: e03a6c0ded5f7088ba59ecd9e97234a6
225
- body:
226
- encoding: UTF-8
227
- string: ! '{"url": "https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Writer%20FAQ.txt",
228
- "expires": "Fri, 20 Sep 2013 19:39:01 +0000"}'
229
- http_version: '1.1'
230
- recorded_at: Fri, 20 Sep 2013 15:39:01 GMT
48
+ encoding: ASCII-8BIT
49
+ string: '{"access_token": "test-access-token",
50
+ "token_type": "bearer", "uid": "test-user-id", "account_id": "dbid:id"}'
51
+ http_version:
52
+ recorded_at: Wed, 01 Nov 2017 15:23:50 GMT
231
53
  - request:
232
- method: get
233
- uri: https://api.dropbox.com/1/media/auto/Writer/Markdown%20Test.txt?
54
+ method: post
55
+ uri: https://api.dropboxapi.com/2/files/list_folder
234
56
  body:
235
57
  encoding: UTF-8
236
- string: ''
58
+ string: '{"recursive":false,"include_media_info":false,"include_deleted":false,"path":""}'
237
59
  headers:
238
- Accept: ! '*/*'
239
- User-Agent: OfficialDropboxRubySDK/1.6.1
240
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
241
- Connection: close
242
- Host: api.dropbox.com
60
+ Authorization:
61
+ - Bearer test-token
62
+ User-Agent:
63
+ - Faraday v0.12.2
64
+ Content-Type:
65
+ - application/json
66
+ Accept-Encoding:
67
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
68
+ Accept:
69
+ - "*/*"
243
70
  response:
244
71
  status:
245
- code: '200'
72
+ code: 200
246
73
  message: OK
247
74
  headers:
248
- Server: nginx
249
- Date: Fri, 20 Sep 2013 15:39:02 GMT
250
- Content-Type: text/javascript
251
- Transfer-Encoding: chunked
252
- Connection: close
253
- set-cookie: ! 'gvc=NjgwODYwOTI2NTA5OTAyNzE3NzE4MDU3MzY0NTQ3NTYyNTYyNDE%3D; expires=Wed,
254
- 19 Sep 2018 15:39:02
255
-
256
- GMT; Path=/; httponly'
257
- x-server-response-time: '78'
258
- x-dropbox-request-id: b6fd9a3c039d2aea3def25f8f2f5ac3a
259
- pragma: no-cache
260
- cache-control: no-cache
261
- x-dropbox-http-protocol: None
262
- x-frame-options: SAMEORIGIN
263
- X-RequestId: 30d2c0cf0122795ebce9bd5f26ce0c60
75
+ Server:
76
+ - nginx
77
+ Date:
78
+ - Thu, 02 Nov 2017 17:24:35 GMT
79
+ Content-Type:
80
+ - application/json
81
+ Transfer-Encoding:
82
+ - chunked
83
+ Connection:
84
+ - keep-alive
85
+ Vary:
86
+ - Accept-Encoding
87
+ Cache-Control:
88
+ - no-cache
89
+ Pragma:
90
+ - no-cache
91
+ X-Content-Type-Options:
92
+ - nosniff
93
+ X-Dropbox-Request-Id:
94
+ - 88a1f2ef2510ba6e8d39629d0950c5cd
95
+ X-Frame-Options:
96
+ - SAMEORIGIN
97
+ X-Server-Response-Time:
98
+ - '420'
264
99
  body:
265
- encoding: UTF-8
266
- string: ! '{"url": "https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Markdown%20Test.txt",
267
- "expires": "Fri, 20 Sep 2013 19:39:02 +0000"}'
268
- http_version: '1.1'
269
- recorded_at: Fri, 20 Sep 2013 15:39:02 GMT
100
+ encoding: ASCII-8BIT
101
+ string: '{"entries": [{".tag": "folder", "name": "Photos", "path_lower": "/photos",
102
+ "path_display": "/Photos", "id": "id:XAAAAAAAAAALA"}, {".tag": "file", "name":
103
+ "Getting Started.pdf", "path_lower": "/getting started.pdf", "path_display":
104
+ "/Getting Started.pdf", "id": "id:XAAAAAAAAAAKg", "client_modified":
105
+ "2012-11-10T18:33:28Z", "server_modified": "2012-11-10T18:33:27Z", "rev":
106
+ "60b9427f2", "size": 249159, "content_hash": "c3dfdd86981548e48bc8efb6c4162c76ba961ec92e60f6ba26189068a41fcaf2"}],
107
+ "cursor": "AAFu-_dOPQTQnqOIb9JklCPYSxWtNRrBBOU4nNkY78wTCc-ktCP4MtIoN1nmOESizkoue2dpu3FbMwDM6BQbgkLObH_Ge-H0BYaPwjfLk5cUHZHd1swkMYGLWELfX_PIHH9hCmU0C8sUL2EJ-7y6BcRFpdOvPmxiu6azVyCx_Il7kA",
108
+ "has_more": false}'
109
+ http_version:
110
+ recorded_at: Thu, 02 Nov 2017 17:24:35 GMT
270
111
  - request:
271
- method: get
272
- uri: https://api.dropbox.com/1/media/auto/Writer/Markdown%20Test.txt
112
+ method: post
113
+ uri: https://api.dropboxapi.com/2/files/list_folder
273
114
  body:
274
115
  encoding: UTF-8
275
- string: ''
116
+ string: '{"recursive":false,"include_media_info":false,"include_deleted":false,"path":"/Photos"}'
276
117
  headers:
277
- Accept: ! '*/*'
278
- User-Agent: OfficialDropboxRubySDK/1.6.1
279
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
280
- Connection: close
281
- Host: api.dropbox.com
118
+ Authorization:
119
+ - Bearer test-token
120
+ User-Agent:
121
+ - Faraday v0.12.2
122
+ Content-Type:
123
+ - application/json
124
+ Accept-Encoding:
125
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
126
+ Accept:
127
+ - "*/*"
282
128
  response:
283
129
  status:
284
- code: '200'
130
+ code: 200
285
131
  message: OK
286
132
  headers:
287
- Server: nginx
288
- Date: Fri, 20 Sep 2013 15:39:02 GMT
289
- Content-Type: text/javascript
290
- Transfer-Encoding: chunked
291
- Connection: close
292
- set-cookie: ! 'gvc=NjgwODYwOTI2NTA5OTAyNzE3NzE4MDU3MzY0NTQ3NTYyNTYyNDE%3D; expires=Wed,
293
- 19 Sep 2018 15:39:02
294
-
295
- GMT; Path=/; httponly'
296
- x-server-response-time: '78'
297
- x-dropbox-request-id: b6fd9a3c039d2aea3def25f8f2f5ac3a
298
- pragma: no-cache
299
- cache-control: no-cache
300
- x-dropbox-http-protocol: None
301
- x-frame-options: SAMEORIGIN
302
- X-RequestId: 30d2c0cf0122795ebce9bd5f26ce0c60
133
+ Server:
134
+ - nginx
135
+ Date:
136
+ - Thu, 02 Nov 2017 18:24:47 GMT
137
+ Content-Type:
138
+ - application/json
139
+ Transfer-Encoding:
140
+ - chunked
141
+ Connection:
142
+ - keep-alive
143
+ Vary:
144
+ - Accept-Encoding
145
+ Cache-Control:
146
+ - no-cache
147
+ Pragma:
148
+ - no-cache
149
+ X-Content-Type-Options:
150
+ - nosniff
151
+ X-Dropbox-Request-Id:
152
+ - 99449c0009a0b11d68c7be3fd95c344e
153
+ X-Frame-Options:
154
+ - SAMEORIGIN
155
+ X-Server-Response-Time:
156
+ - '249'
303
157
  body:
304
- encoding: UTF-8
305
- string: ! '{"url": "https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Markdown%20Test.txt",
306
- "expires": "Fri, 20 Sep 2013 19:39:02 +0000"}'
307
- http_version: '1.1'
308
- recorded_at: Fri, 20 Sep 2013 15:39:02 GMT
158
+ encoding: ASCII-8BIT
159
+ string: '{"entries": [{".tag": "folder", "name": "Sample Album", "path_lower":
160
+ "/photos/sample album", "path_display": "/Photos/Sample Album", "id": "id:XAAAAAAAAAAKw"}],
161
+ "cursor": "AAGbwaeSAvSMoUMUP1PFBFovGux_ng7wnPb1sj0d7ovjMe6lvtB0NG1xwOtwFWfyNjIHPx1gkKGFSxn-6A5WsL59EZKn3XbJxk1kZzNTtwcDCVj2GIG7cHSTnCdjeAeNf1e6VEpsaXdnh67WrSjSUu9fsfok4H83z_JlXT1LZ_XVCA",
162
+ "has_more": false}'
163
+ http_version:
164
+ recorded_at: Thu, 02 Nov 2017 18:24:47 GMT
309
165
  - request:
310
- method: get
311
- uri: https://api.dropbox.com/1/metadata/auto/Writer/Writer%20FAQ.txt?file_limit=25000&include_deleted=false&include_media_info=false&list=true
166
+ method: post
167
+ uri: https://api.dropboxapi.com/2/files/get_metadata
312
168
  body:
313
169
  encoding: UTF-8
314
- string: ''
170
+ string: '{"path":"/Getting Started.pdf"}'
315
171
  headers:
316
- Accept: ! '*/*'
317
- User-Agent: OfficialDropboxRubySDK/1.6.1
318
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
319
- Connection: close
320
- Host: api.dropbox.com
172
+ Authorization:
173
+ - Bearer test-token
174
+ User-Agent:
175
+ - Faraday v0.12.2
176
+ Content-Type:
177
+ - application/json
178
+ Accept-Encoding:
179
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
180
+ Accept:
181
+ - "*/*"
321
182
  response:
322
183
  status:
323
- code: '200'
184
+ code: 200
324
185
  message: OK
325
186
  headers:
326
- Server: nginx
327
- Date: Fri, 20 Sep 2013 15:38:55 GMT
328
- Content-Type: text/javascript
329
- Transfer-Encoding: chunked
330
- Connection: close
331
- set-cookie: ! 'gvc=Njg4MTEzOTAzNjIxMzA3Mzg0Nzk4ODMwMjc3ODE5Mjk1OTIyMjY%3D; expires=Wed,
332
- 19 Sep 2018 15:38:55
333
-
334
- GMT; Path=/; httponly'
335
- x-server-response-time: '64'
336
- x-dropbox-request-id: 349e4a2b10c59d22f4e686ddbd608b69
337
- pragma: no-cache
338
- cache-control: no-cache
339
- x-dropbox-http-protocol: None
340
- x-frame-options: SAMEORIGIN
341
- X-RequestId: 83bc363934d5a5457cbcbd0fab8b4cfb
187
+ Server:
188
+ - nginx
189
+ Date:
190
+ - Thu, 02 Nov 2017 18:24:47 GMT
191
+ Content-Type:
192
+ - application/json
193
+ Transfer-Encoding:
194
+ - chunked
195
+ Connection:
196
+ - keep-alive
197
+ Vary:
198
+ - Accept-Encoding
199
+ Cache-Control:
200
+ - no-cache
201
+ Pragma:
202
+ - no-cache
203
+ X-Content-Type-Options:
204
+ - nosniff
205
+ X-Dropbox-Request-Id:
206
+ - 759ea34f57056e7d7fdf96cf4548014b
207
+ X-Frame-Options:
208
+ - SAMEORIGIN
209
+ X-Server-Response-Time:
210
+ - '170'
342
211
  body:
343
- encoding: UTF-8
344
- string: ! '{ "revision": 4009, "rev": "fa900cbb190", "thumb_exists": false, "bytes": 20904,
345
- "modified": "Sat, 09 Apr 2011 18:54:54 +0000", "client_mtime": "Sat, 09 Apr 2011 18:54:54 +0000",
346
- "path": "/Writer/Writer FAQ.txt", "is_dir": false, "icon": "page_white_text", "root":
347
- "dropbox", "mime_type": "text/plain", "size": "20.4 KB" }'
348
- http_version: '1.1'
349
- recorded_at: Fri, 20 Sep 2013 15:38:55 GMT
212
+ encoding: ASCII-8BIT
213
+ string: '{".tag": "file", "name": "Getting Started.pdf", "path_lower": "/getting
214
+ started.pdf", "path_display": "/Getting Started.pdf", "id": "id:XAAAAAAAAAAKw",
215
+ "client_modified": "2012-11-10T18:33:28Z", "server_modified": "2012-11-10T18:33:27Z",
216
+ "rev": "60b9427f2", "size": 249159, "content_hash": "c3dfdd86981548e48bc8efb6c4162c76ba961ec92e60f6ba26189068a41fcaf2"}'
217
+ http_version:
218
+ recorded_at: Thu, 02 Nov 2017 18:24:47 GMT
350
219
  - request:
351
- method: get
352
- uri: https://api.dropbox.com/1/metadata/auto/Writer/Markdown%20Test.txt?file_limit=25000&include_deleted=false&include_media_info=false&list=true
220
+ method: post
221
+ uri: https://content.dropboxapi.com/2/files/download
353
222
  body:
354
223
  encoding: UTF-8
355
224
  string: ''
356
225
  headers:
357
- Accept: ! '*/*'
358
- User-Agent: OfficialDropboxRubySDK/1.6.1
359
- Authorization: Bearer FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321
360
- Connection: close
361
- Host: api.dropbox.com
226
+ Authorization:
227
+ - Bearer test-token
228
+ User-Agent:
229
+ - Faraday v0.12.2
230
+ Dropbox-Api-Arg:
231
+ - '{"path":"/Getting Started.pdf"}'
232
+ Content-Type:
233
+ - ''
234
+ Content-Length:
235
+ - '0'
236
+ Accept-Encoding:
237
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
238
+ Accept:
239
+ - "*/*"
362
240
  response:
363
241
  status:
364
- code: '200'
242
+ code: 200
365
243
  message: OK
366
244
  headers:
367
- Server: nginx
368
- Date: Fri, 20 Sep 2013 15:38:55 GMT
369
- Content-Type: text/javascript
370
- Transfer-Encoding: chunked
371
- Connection: close
372
- set-cookie: ! 'gvc=Njg4MTEzOTAzNjIxMzA3Mzg0Nzk4ODMwMjc3ODE5Mjk1OTIyMjY%3D; expires=Wed,
373
- 19 Sep 2018 15:38:55
374
-
375
- GMT; Path=/; httponly'
376
- x-server-response-time: '64'
377
- x-dropbox-request-id: 349e4a2b10c59d22f4e686ddbd608b69
378
- pragma: no-cache
379
- cache-control: no-cache
380
- x-dropbox-http-protocol: None
381
- x-frame-options: SAMEORIGIN
382
- X-RequestId: 83bc363934d5a5457cbcbd0fab8b4cfb
245
+ Server:
246
+ - nginx
247
+ Date:
248
+ - Thu, 02 Nov 2017 17:24:36 GMT
249
+ Content-Type:
250
+ - application/octet-stream
251
+ Content-Length:
252
+ - '249159'
253
+ Connection:
254
+ - keep-alive
255
+ Accept-Ranges:
256
+ - bytes
257
+ Etag:
258
+ - W/"60b9427f2"
259
+ Pragma:
260
+ - no-cache
261
+ Cache-Control:
262
+ - no-cache
263
+ Original-Content-Length:
264
+ - '249159'
265
+ Dropbox-Api-Result:
266
+ - '{"name": "Getting Started.pdf", "path_lower": "/getting started.pdf", "path_display":
267
+ "/Getting Started.pdf", "id": "id:XAAAAAAAAAAKg", "client_modified":
268
+ "2012-11-10T18:33:28Z", "server_modified": "2012-11-10T18:33:27Z", "rev":
269
+ "60b9427f2", "size": 249159, "content_hash": "c3dfdd86981548e48bc8efb6c4162c76ba961ec92e60f6ba26189068a41fcaf2"}'
270
+ X-Server-Response-Time:
271
+ - '568'
272
+ X-Dropbox-Request-Id:
273
+ - 34e2c5d045bc37e50c1874f668a6c8c6
274
+ X-Robots-Tag:
275
+ - noindex, nofollow, noimageindex
383
276
  body:
384
- encoding: UTF-8
385
- string: ! '{ "revision": 2754, "rev": "ac200cbb190", "thumb_exists": false,
386
- "bytes": 988, "modified": "Thu, 14 Oct 2010 08:32:20 +0000",
387
- "client_mtime": "Thu, 14 Oct 2010 08:32:20 +0000",
388
- "path": "/Writer/Markdown Test.txt", "is_dir": false, "icon": "page_white_text",
389
- "root": "dropbox", "mime_type": "text/plain", "size": "988 bytes" }'
390
- http_version: '1.1'
391
- recorded_at: Fri, 20 Sep 2013 15:38:55 GMT
392
- recorded_with: Charles Proxy
277
+ encoding: ASCII-8BIT
278
+ string: !binary |-
279
+ JVBERi0xLjcNJeLjz9MNCjU5IDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDI0
280
+ http_version:
281
+ recorded_at: Thu, 02 Nov 2017 17:24:36 GMT
282
+ recorded_with: VCR 3.0.3
data/spec/spec_helper.rb CHANGED
@@ -53,8 +53,8 @@ module BrowserConfigHelper
53
53
  client_secret: 'BoxClientSecret'
54
54
  },
55
55
  'dropbox' => {
56
- app_key: 'DropboxAppKey',
57
- app_secret: 'DropboxAppSecret'
56
+ client_id: 'DropboxId',
57
+ client_secret: 'DropboxClientSecret'
58
58
  },
59
59
  'google_drive' => {
60
60
  client_id: 'GoogleClientId',
@@ -3,23 +3,23 @@ include BrowserConfigHelper
3
3
  describe BrowseEverything::Browser do
4
4
  let(:file_config) do
5
5
  {
6
- file_system: { home: '/file/config/home' },
7
- dropbox: { app_key: 'FileConfigKey', app_secret: 'FileConfigSecret' }
6
+ file_system: { home: '/file/config/home' },
7
+ dropbox: { client_id: 'DropboxId', client_secret: 'DropboxClientSecret' }
8
8
  }.to_yaml
9
9
  end
10
10
 
11
11
  let(:global_config) do
12
12
  {
13
- file_system: { home: '/global/config/home' },
14
- dropbox: { app_key: 'GlobalConfigKey', app_secret: 'GlobalConfigSecret' }
13
+ file_system: { home: '/global/config/home' },
14
+ dropbox: { client_id: 'DropboxId', client_secret: 'DropboxClientSecret' }
15
15
  }
16
16
  end
17
17
 
18
18
  let(:local_config) do
19
19
  {
20
- file_system: { home: '/local/config/home' },
21
- dropbox: { app_key: 'LocalConfigKey', app_secret: 'LocalConfigSecret' },
22
- url_options: url_options
20
+ file_system: { home: '/local/config/home' },
21
+ dropbox: { client_id: 'DropboxId', client_secret: 'DropboxClientSecret' },
22
+ url_options: url_options
23
23
  }
24
24
  end
25
25
 
@@ -33,7 +33,7 @@ describe BrowseEverything::Browser do
33
33
  end
34
34
 
35
35
  it 'uses the file configuration' do
36
- expect(browser.providers[:dropbox].config[:app_key]).to eq('FileConfigKey')
36
+ expect(browser.providers[:file_system].config[:home]).to eq('/file/config/home')
37
37
  end
38
38
  end
39
39
 
@@ -47,7 +47,7 @@ describe BrowseEverything::Browser do
47
47
  end
48
48
 
49
49
  it 'uses the global configuration' do
50
- expect(browser.providers[:dropbox].config[:app_key]).to eq('GlobalConfigKey')
50
+ expect(browser.providers[:file_system].config[:home]).to eq('/global/config/home')
51
51
  end
52
52
  end
53
53
 
@@ -59,7 +59,7 @@ describe BrowseEverything::Browser do
59
59
  end
60
60
 
61
61
  it 'uses the local configuration' do
62
- expect(browser.providers[:dropbox].config[:app_key]).to eq('LocalConfigKey')
62
+ expect(browser.providers[:file_system].config[:home]).to eq('/local/config/home')
63
63
  end
64
64
  end
65
65
 
@@ -6,15 +6,21 @@ describe BrowseEverything::Driver::Dropbox, vcr: { cassette_name: 'dropbox', rec
6
6
 
7
7
  let(:browser) { BrowseEverything::Browser.new(url_options) }
8
8
  let(:provider) { browser.providers['dropbox'] }
9
- let(:auth_params) do {
10
- 'code' => 'FakeDropboxAuthorizationCodeABCDEFG',
11
- 'state' => 'GjDcUhPNZrZzdsw%2FghBy2A%3D%3D|dropbox'
12
- }
9
+ let(:provider_yml) do
10
+ {
11
+ client_id: 'client-id',
12
+ client_secret: 'client-secret'
13
+ }
13
14
  end
14
- let(:csrf_data) { { 'token' => 'GjDcUhPNZrZzdsw%2FghBy2A%3D%3D' } }
15
15
 
16
- it '#validate_config' do
17
- expect { BrowseEverything::Driver::Dropbox.new({}) }.to raise_error(BrowseEverything::InitializationError)
16
+ describe '#validate_config' do
17
+ it 'raises and error with an incomplete configuration' do
18
+ expect { BrowseEverything::Driver::Dropbox.new({}) }.to raise_error(BrowseEverything::InitializationError)
19
+ end
20
+
21
+ it 'raises and error with a configuration without a client secret' do
22
+ expect { BrowseEverything::Driver::Dropbox.new(client_id: 'test-client-id') }.to raise_error(BrowseEverything::InitializationError)
23
+ end
18
24
  end
19
25
 
20
26
  describe 'simple properties' do
@@ -24,101 +30,64 @@ describe BrowseEverything::Driver::Dropbox, vcr: { cassette_name: 'dropbox', rec
24
30
  its(:icon) { is_expected.to be_a(String) }
25
31
  end
26
32
 
27
- describe '#auth_link' do
28
- subject { provider.auth_link[0] }
29
-
30
- it { is_expected.to start_with('https://www.dropbox.com/1/oauth2/authorize') }
31
- it { is_expected.to include('browse%2Fconnect') }
32
- it { is_expected.to include('state') }
33
- end
34
-
35
- describe 'authorization' do
36
- subject { provider }
37
- before { provider.connect(auth_params, csrf_data) }
38
- it { is_expected.to be_authorized }
39
- end
33
+ context 'with a valid configuration' do
34
+ let(:driver) { described_class.new(provider_yml) }
35
+ before { driver.connect({ code: 'code' }, {}) }
40
36
 
41
- describe '#contents' do
42
- before { provider.connect(auth_params, csrf_data) }
43
-
44
- context 'root directory' do
45
- let(:contents) { provider.contents('') }
46
-
47
- context '[0]' do
48
- subject { contents[0] }
49
- its(:name) { is_expected.to eq('Apps') }
50
- specify { is_expected.to be_container }
51
- end
52
- context '[1]' do
53
- subject { contents[1] }
54
- its(:name) { is_expected.to eq('Books') }
55
- specify { is_expected.to be_container }
56
- end
57
- context '[4]' do
58
- subject { contents[4] }
59
- its(:name) { is_expected.to eq('iPad intro.pdf') }
60
- its(:size) { is_expected.to eq(208218) }
61
- its(:location) { is_expected.to eq('dropbox:/iPad intro.pdf') }
62
- its(:type) { is_expected.to eq('application/pdf') }
63
- specify { is_expected.not_to be_container }
64
- end
37
+ describe '#auth_link' do
38
+ subject { driver.auth_link }
39
+ it { is_expected.to start_with('https://www.dropbox.com/oauth2/authorize') }
65
40
  end
66
41
 
67
- context 'subdirectory' do
68
- let(:contents) { provider.contents('/Writer') }
69
- context '[0]' do
70
- subject { contents[0] }
71
-
72
- its(:name) { is_expected.to eq('..') }
73
- specify { is_expected.to be_container }
74
- end
75
- context '[1]' do
76
- subject { contents[1] }
77
-
78
- its(:name) { is_expected.to eq('About Writer.txt') }
79
- its(:location) { is_expected.to eq('dropbox:/Writer/About Writer.txt') }
80
- its(:type) { is_expected.to eq('text/plain') }
81
- specify { is_expected.not_to be_container }
82
- end
83
- context '[2]' do
84
- subject { contents[2] }
85
-
86
- its(:name) { is_expected.to eq('Markdown Test.txt') }
87
- its(:location) { is_expected.to eq('dropbox:/Writer/Markdown Test.txt') }
88
- its(:type) { is_expected.to eq('text/plain') }
89
- specify { is_expected.not_to be_container }
90
- end
91
- context '[3]' do
92
- subject { contents[3] }
42
+ describe '#authorized?' do
43
+ subject { driver }
44
+ it { is_expected.to be_authorized }
45
+ end
93
46
 
94
- its(:name) { is_expected.to eq('Writer FAQ.txt') }
95
- its(:location) { is_expected.to eq('dropbox:/Writer/Writer FAQ.txt') }
96
- its(:type) { is_expected.to eq('text/plain') }
97
- specify { is_expected.not_to be_container }
47
+ describe '#contents' do
48
+ context 'within the root folder' do
49
+ let(:contents) { driver.contents }
50
+
51
+ it 'retrieves all folders the root folders' do
52
+ expect(contents).not_to be_empty
53
+ folder_metadata = contents.first
54
+ expect(folder_metadata).to be_a BrowseEverything::FileEntry
55
+ expect(folder_metadata.id).to eq '/Photos'
56
+ expect(folder_metadata.location).to eq 'dropbox:/Photos'
57
+ expect(folder_metadata.name).to eq 'Photos'
58
+ expect(folder_metadata.size).to eq nil
59
+ expect(folder_metadata.mtime).to eq nil
60
+ expect(folder_metadata.container?).to eq true
61
+ end
98
62
  end
99
63
  end
100
64
 
101
- context '#details' do
102
- subject { provider.details('') }
103
- its(:name) { is_expected.to eq('Apps') }
65
+ describe '#details' do
66
+ subject(:file_metadata) { driver.details('/Getting Started.pdf') }
67
+
68
+ it 'retrieves the metadata for a file' do
69
+ expect(file_metadata).to be_a BrowseEverything::FileEntry
70
+ expect(file_metadata.id).to eq '/Getting Started.pdf'
71
+ expect(file_metadata.location).to eq 'dropbox:/Getting Started.pdf'
72
+ expect(file_metadata.name).to eq 'Getting Started.pdf'
73
+ expect(file_metadata.size).to eq 249159
74
+ expect(file_metadata.mtime).to be_a Time
75
+ expect(file_metadata.container?).to eq false
76
+ end
104
77
  end
105
- end
106
-
107
- describe '#link_for' do
108
- before { provider.connect(auth_params, csrf_data) }
109
78
 
110
- context '[0]' do
111
- let(:link) { provider.link_for('/Writer/Writer FAQ.txt') }
79
+ describe '#link_for' do
80
+ subject(:link_args) { driver.link_for('/Getting Started.pdf') }
112
81
 
113
- specify { expect(link[0]).to eq('https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Writer%20FAQ.txt') }
114
- specify { expect(link[1]).to have_key(:expires) }
115
- end
116
-
117
- context '[1]' do
118
- let(:link) { provider.link_for('/Writer/Markdown Test.txt') }
82
+ it 'provides link arguments for accessing the file' do
83
+ expect(link_args.first).to be_a String
84
+ expect(link_args.first).to start_with 'file:/'
85
+ expect(link_args.first).to include 'Getting Started.pdf'
119
86
 
120
- specify { expect(link[0]).to eq('https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Markdown%20Test.txt') }
121
- specify { expect(link[1]).to have_key(:expires) }
87
+ File.open(link_args.first.gsub('file:', '')) do |downloaded_file|
88
+ expect(downloaded_file.read).not_to be_empty
89
+ end
90
+ end
122
91
  end
123
92
  end
124
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browse-everything
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carolyn Cole
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-10-11 00:00:00.000000000 Z
16
+ date: 2017-12-09 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -58,19 +58,19 @@ dependencies:
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  - !ruby/object:Gem::Dependency
61
- name: dropbox-sdk
61
+ name: dropbox_api
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 1.6.2
66
+ version: 0.1.10
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 1.6.2
73
+ version: 0.1.10
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: ruby-box
76
76
  requirement: !ruby/object:Gem::Requirement
@@ -554,7 +554,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
554
554
  version: '0'
555
555
  requirements: []
556
556
  rubyforge_project:
557
- rubygems_version: 2.6.13
557
+ rubygems_version: 2.5.2.1
558
558
  signing_key:
559
559
  specification_version: 4
560
560
  summary: AJAX/Rails engine file browser for cloud storage services