browse-everything 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +14 -44
- data/app/helpers/font_awesome_version_helper.rb +0 -1
- data/app/services/browse_everything_session.rb +0 -1
- data/app/services/browser_factory.rb +0 -1
- data/browse-everything.gemspec +4 -3
- data/lib/browse_everything.rb +2 -2
- data/lib/browse_everything/driver/dropbox.rb +3 -1
- data/lib/browse_everything/file_entry.rb +1 -1
- data/lib/browse_everything/retriever.rb +1 -1
- data/lib/browse_everything/version.rb +1 -1
- data/lib/generators/browse_everything/config_generator.rb +2 -2
- data/spec/controllers/browse_everything_controller_spec.rb +1 -0
- data/spec/features/select_files_spec.rb +2 -0
- data/spec/fixtures/config/browse_everything_providers.yml +10 -0
- data/spec/lib/browse_everything/auth/google/credentials_spec.rb +3 -2
- data/spec/lib/browse_everything/browse_everything_helper_spec.rb +1 -1
- data/spec/lib/browse_everything/browser_spec.rb +1 -0
- data/spec/lib/browse_everything/driver/base_spec.rb +3 -0
- data/spec/lib/browse_everything/driver/box_spec.rb +8 -0
- data/spec/lib/browse_everything/driver/file_system_spec.rb +3 -0
- data/spec/lib/browse_everything/driver/s3_spec.rb +6 -3
- data/spec/lib/browse_everything/driver_spec.rb +4 -5
- data/spec/lib/browse_everything/retriever_spec.rb +15 -14
- data/spec/lib/browse_everything_spec.rb +57 -40
- data/spec/services/browse_everything_session/provider_session_spec.rb +3 -0
- data/spec/spec_helper.rb +4 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/browse_everything/_files.html.erb_spec.rb +1 -0
- metadata +41 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36223786bc3a801a4cde821810d4e8976f0a1034fcc228acaea6a7eba411770e
|
4
|
+
data.tar.gz: 1611bfb8566183526c1489bb3de4dd8beac2147c7cf0b637d18a445267984daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f835658832bc8837d99c18f4e3dae6a5e8d1edebb183950022a3d44c9b309e04437853d727449b1c0705eaf959fa43ab62c7b5c50ccc78298d6b3d6d2d0e0c
|
7
|
+
data.tar.gz: a725066448c474d91fd38590dbc470ce5bdcf5cf7e60df0721a7ddfbc122fd004a23c99688565ca368610da3adf77f8b95d0bd383f940cf0285d4c189638756e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
|
+
inherit_gem:
|
3
|
+
bixby: bixby_default.yml
|
2
4
|
|
3
5
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.3
|
5
7
|
DisplayCopNames: true
|
6
|
-
Include:
|
7
|
-
- '**/Rakefile'
|
8
8
|
Exclude:
|
9
9
|
- 'vendor/**/*'
|
10
10
|
|
@@ -22,21 +22,8 @@ Metrics/LineLength:
|
|
22
22
|
Max: 400
|
23
23
|
Metrics/BlockLength:
|
24
24
|
Exclude:
|
25
|
-
- '
|
26
|
-
- 'spec
|
27
|
-
- 'spec/unit/browse_everything/retriever_spec.rb'
|
28
|
-
- 'spec/unit/browse_everything/file_entry_spec.rb'
|
29
|
-
- 'spec/unit/browse_everything/driver/s3_spec.rb'
|
30
|
-
- 'spec/unit/browse_everything/driver/google_drive_spec.rb'
|
31
|
-
- 'spec/unit/browse_everything/driver/file_system_spec.rb'
|
32
|
-
- 'spec/unit/browse_everything/driver/dropbox_spec.rb'
|
33
|
-
- 'spec/unit/browse_everything/driver/box_spec.rb'
|
34
|
-
- 'spec/unit/browse_everything/browser_spec.rb'
|
35
|
-
- 'spec/services/browser_factory_spec.rb'
|
36
|
-
- 'spec/services/browse_everything_session/provider_session_spec.rb'
|
37
|
-
- 'spec/helper/browse_everything_controller_helper_spec.rb'
|
38
|
-
- 'spec/controllers/browse_everything_controller_spec.rb'
|
39
|
-
- 'browse-everything.gemspec'
|
25
|
+
- '*.gemspec'
|
26
|
+
- 'spec/**/*'
|
40
27
|
|
41
28
|
RSpec/NestedGroups:
|
42
29
|
Enabled: false
|
@@ -45,27 +32,10 @@ RSpec/LeadingSubject:
|
|
45
32
|
Enabled: false
|
46
33
|
|
47
34
|
RSpec/ExampleLength:
|
48
|
-
|
49
|
-
- 'spec/unit/browse_everything/driver/base_spec.rb'
|
50
|
-
- 'spec/unit/browse_everything/driver/box_spec.rb'
|
51
|
-
- 'spec/unit/browse_everything/driver/dropbox_spec.rb'
|
52
|
-
- 'spec/unit/browse_everything/driver/file_system_spec.rb'
|
53
|
-
- 'spec/unit/browse_everything/driver/google_drive_spec.rb'
|
54
|
-
- 'spec/unit/browse_everything/driver/s3_spec.rb'
|
55
|
-
- 'spec/features/select_files_spec.rb'
|
56
|
-
- 'spec/javascripts/jasmine_spec.rb'
|
35
|
+
Enabled: false
|
57
36
|
|
58
37
|
RSpec/MultipleExpectations:
|
59
|
-
|
60
|
-
- 'spec/unit/browse_everything/driver/base_spec.rb'
|
61
|
-
- 'spec/unit/browse_everything/driver/box_spec.rb'
|
62
|
-
- 'spec/unit/browse_everything/driver/dropbox_spec.rb'
|
63
|
-
- 'spec/unit/browse_everything/driver/file_system_spec.rb'
|
64
|
-
- 'spec/unit/browse_everything/driver/google_drive_spec.rb'
|
65
|
-
- 'spec/unit/browse_everything/driver/s3_spec.rb'
|
66
|
-
- 'spec/features/**/*'
|
67
|
-
- 'spec/controllers/browse_everything_controller_spec.rb'
|
68
|
-
- 'spec/unit/browse_everything/browser_spec.rb'
|
38
|
+
Enabled: false
|
69
39
|
|
70
40
|
Style/NumericLiterals:
|
71
41
|
MinDigits: 7
|
@@ -81,13 +51,13 @@ Naming/FileName:
|
|
81
51
|
|
82
52
|
Style/MixinUsage:
|
83
53
|
Exclude:
|
84
|
-
- 'spec/
|
85
|
-
- 'spec/
|
86
|
-
- 'spec/
|
87
|
-
- 'spec/
|
88
|
-
- 'spec/
|
89
|
-
- 'spec/
|
90
|
-
- 'spec/
|
54
|
+
- 'spec/lib/browse_everything/driver/s3_spec.rb'
|
55
|
+
- 'spec/lib/browse_everything/driver/google_drive_spec.rb'
|
56
|
+
- 'spec/lib/browse_everything/driver/file_system_spec.rb'
|
57
|
+
- 'spec/lib/browse_everything/driver/dropbox_spec.rb'
|
58
|
+
- 'spec/lib/browse_everything/driver/box_spec.rb'
|
59
|
+
- 'spec/lib/browse_everything/driver/base_spec.rb'
|
60
|
+
- 'spec/lib/browse_everything/browser_spec.rb'
|
91
61
|
- 'spec/services/browser_factory_spec.rb'
|
92
62
|
- 'spec/helper/browse_everything_controller_helper_spec.rb'
|
93
63
|
|
data/browse-everything.gemspec
CHANGED
@@ -26,13 +26,15 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency 'font-awesome-rails'
|
27
27
|
spec.add_dependency 'google-api-client', '~> 0.21'
|
28
28
|
spec.add_dependency 'google_drive', '~> 2.1'
|
29
|
-
spec.add_dependency '
|
29
|
+
spec.add_dependency 'googleauth', '0.6.2'
|
30
30
|
spec.add_dependency 'rails', '>= 4.2'
|
31
31
|
spec.add_dependency 'ruby-box'
|
32
32
|
spec.add_dependency 'sass-rails'
|
33
33
|
spec.add_dependency 'signet', '~> 0.8'
|
34
34
|
spec.add_dependency 'thor', '~> 0.20'
|
35
|
+
spec.add_dependency 'typhoeus'
|
35
36
|
|
37
|
+
spec.add_development_dependency 'bixby', '>= 1.0'
|
36
38
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
37
39
|
spec.add_development_dependency 'capybara'
|
38
40
|
spec.add_development_dependency 'chromedriver-helper'
|
@@ -45,8 +47,7 @@ Gem::Specification.new do |spec|
|
|
45
47
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
46
48
|
spec.add_development_dependency 'rspec-its'
|
47
49
|
spec.add_development_dependency 'rspec-rails'
|
48
|
-
spec.add_development_dependency 'rubocop'
|
49
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 1.23'
|
50
|
+
spec.add_development_dependency 'rubocop-rspec'
|
50
51
|
spec.add_development_dependency 'selenium-webdriver'
|
51
52
|
spec.add_development_dependency 'simplecov'
|
52
53
|
spec.add_development_dependency 'sqlite3'
|
data/lib/browse_everything.rb
CHANGED
@@ -53,14 +53,14 @@ module BrowseEverything
|
|
53
53
|
elsif value.is_a?(String)
|
54
54
|
config_file_content = File.read(value)
|
55
55
|
config_file_template = ERB.new(config_file_content)
|
56
|
-
config_values = YAML.safe_load(config_file_template.result)
|
56
|
+
config_values = YAML.safe_load(config_file_template.result, [Symbol])
|
57
57
|
@config = ActiveSupport::HashWithIndifferentAccess.new config_values
|
58
58
|
@config.deep_symbolize_keys
|
59
59
|
else
|
60
60
|
raise InitializationError, "Unrecognized configuration: #{value.inspect}"
|
61
61
|
end
|
62
62
|
|
63
|
-
if @config.include? 'drop_box'
|
63
|
+
if @config.include? 'drop_box' # rubocop:disable Style/GuardClause
|
64
64
|
warn '[DEPRECATION] `drop_box` is deprecated. Please use `dropbox` instead.'
|
65
65
|
@config['dropbox'] = @config.delete('drop_box')
|
66
66
|
end
|
@@ -131,7 +131,7 @@ module BrowseEverything
|
|
131
131
|
url = options.fetch(:url)
|
132
132
|
retrieved = 0
|
133
133
|
|
134
|
-
request = Typhoeus::Request.new(url.to_s)
|
134
|
+
request = Typhoeus::Request.new(url.to_s, headers: headers)
|
135
135
|
request.on_headers do |response|
|
136
136
|
raise DownloadError.new("#{self.class}: Failed to download #{url}", response) unless response.code == 200
|
137
137
|
end
|
@@ -7,7 +7,7 @@ class BrowseEverything::ConfigGenerator < Rails::Generators::Base
|
|
7
7
|
This generator makes the following changes to your application:
|
8
8
|
1. Creates config/browse_everything_providers.yml with a placeholder value
|
9
9
|
2. Modifies your app's routes.rb to mount BrowseEverything at /browse
|
10
|
-
|
10
|
+
DESC
|
11
11
|
source_root File.expand_path('templates', __dir__)
|
12
12
|
|
13
13
|
def inject_routes
|
@@ -18,7 +18,7 @@ class BrowseEverything::ConfigGenerator < Rails::Generators::Base
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def copy_example_config
|
21
|
-
FileUtils.rm 'config/browse_everything_providers.yml', force: true if File.
|
21
|
+
FileUtils.rm 'config/browse_everything_providers.yml', force: true if File.exist? 'config/browse_everything_providers.yml'
|
22
22
|
copy_file 'browse_everything_providers.yml.example', 'config/browse_everything_providers.yml', force: true
|
23
23
|
end
|
24
24
|
|
@@ -22,6 +22,7 @@ RSpec.describe BrowseEverythingController, type: :controller do
|
|
22
22
|
allow(provider).to receive(:connect)
|
23
23
|
controller.auth
|
24
24
|
end
|
25
|
+
|
25
26
|
it 'retrieves the authorization code from the parameters' do
|
26
27
|
expect(provider).to have_received(:connect).with({ 'code' => 'test-code' }, nil)
|
27
28
|
end
|
@@ -26,11 +26,13 @@ describe 'Choosing files', type: :feature, js: true do
|
|
26
26
|
|
27
27
|
context 'when Turbolinks are enabled', fail: true do
|
28
28
|
before { click_link('Enter Test App (Turbolinks)') }
|
29
|
+
|
29
30
|
it_behaves_like 'browseable files'
|
30
31
|
end
|
31
32
|
|
32
33
|
context 'when Turbolinks are disabled' do
|
33
34
|
before { click_link('Enter Test App (No Turbolinks)') }
|
35
|
+
|
34
36
|
it_behaves_like 'browseable files'
|
35
37
|
end
|
36
38
|
end
|
@@ -5,24 +5,25 @@ describe BrowseEverything::Auth::Google::Credentials do
|
|
5
5
|
|
6
6
|
describe '#fetch_access_token' do
|
7
7
|
let(:response) { double }
|
8
|
+
|
8
9
|
before do
|
9
10
|
WebMock.disable!
|
10
11
|
|
11
12
|
allow(response).to receive(:status_code).and_return('200')
|
12
13
|
allow(response).to receive(:body).and_return('{}')
|
13
|
-
allow(response).to receive(:header).and_return(
|
14
|
+
allow(response).to receive(:header).and_return(content_type: 'application/json')
|
14
15
|
|
15
16
|
connection = instance_double(Faraday::Connection)
|
16
17
|
allow(connection).to receive(:post).and_return(response)
|
17
18
|
faraday = class_double('Faraday').as_stubbed_const(transfer_nested_constants: true)
|
18
19
|
allow(faraday).to receive(:default_connection).and_return(connection)
|
19
|
-
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'when an access has already been retrieved' do
|
23
23
|
before do
|
24
24
|
credentials.access_token = 'test-token'
|
25
25
|
end
|
26
|
+
|
26
27
|
it 'generates a Hash if an access token has already been set' do
|
27
28
|
expect(credentials.fetch_access_token).to be_a Hash
|
28
29
|
expect(credentials.fetch_access_token).to include('access_token' => 'test-token')
|
@@ -11,7 +11,7 @@ describe BrowseEverythingHelper do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:test_file) { BrowseEverything::FileEntry.new 0, '/path/to/file.mp4', 'file.mp4', 12345, Time.
|
14
|
+
let(:test_file) { BrowseEverything::FileEntry.new 0, '/path/to/file.mp4', 'file.mp4', 12345, Time.current, false }
|
15
15
|
|
16
16
|
it 'matches a full type' do
|
17
17
|
expect(test_class.new(accept: 'video/mp4').is_acceptable?(test_file)).to eq(true)
|
@@ -102,6 +102,7 @@ describe BrowseEverything::Browser do
|
|
102
102
|
|
103
103
|
describe '#first_provider' do
|
104
104
|
subject(:browser) { described_class.new(url_options) }
|
105
|
+
|
105
106
|
it 'retrieves the first configured provider' do
|
106
107
|
expect(browser.first_provider).to be_a BrowseEverything::Driver::FileSystem
|
107
108
|
end
|
@@ -14,16 +14,19 @@ describe BrowseEverything::Driver::Base do
|
|
14
14
|
its(:auth_link) { is_expected.to be_empty }
|
15
15
|
specify { is_expected.not_to be_authorized }
|
16
16
|
end
|
17
|
+
|
17
18
|
describe '#connect' do
|
18
19
|
subject { driver.connect({}, {}) }
|
19
20
|
|
20
21
|
it { is_expected.to be_blank }
|
21
22
|
end
|
23
|
+
|
22
24
|
describe '#contents' do
|
23
25
|
subject { driver.contents('') }
|
24
26
|
|
25
27
|
it { is_expected.to be_empty }
|
26
28
|
end
|
29
|
+
|
27
30
|
describe '#link_for' do
|
28
31
|
subject { driver.link_for('/path/to/foo.txt') }
|
29
32
|
|
@@ -66,16 +66,22 @@ describe BrowseEverything::Driver::Box, vcr: { cassette_name: 'box', record: :no
|
|
66
66
|
context 'when the access token is not registered' do
|
67
67
|
it { is_expected.to be(false) }
|
68
68
|
end
|
69
|
+
|
69
70
|
context 'when the access tokens are registered and not expired' do
|
70
71
|
before { provider.token = token.merge('expires_at' => Time.now.to_i + 360) }
|
72
|
+
|
71
73
|
it { is_expected.to be(true) }
|
72
74
|
end
|
75
|
+
|
73
76
|
context 'when the access tokens are registered but no expiration time' do
|
74
77
|
before { provider.token = token }
|
78
|
+
|
75
79
|
it { is_expected.to be(false) }
|
76
80
|
end
|
81
|
+
|
77
82
|
context 'when the access tokens are registered but expired' do
|
78
83
|
before { provider.token = token.merge('expires_at' => Time.now.to_i - 360) }
|
84
|
+
|
79
85
|
it { is_expected.to be(false) }
|
80
86
|
end
|
81
87
|
end
|
@@ -143,6 +149,7 @@ describe BrowseEverything::Driver::Box, vcr: { cassette_name: 'box', record: :no
|
|
143
149
|
its(:id) { is_expected.to be_kind_of(Pathname) }
|
144
150
|
it { is_expected.to be_container }
|
145
151
|
end
|
152
|
+
|
146
153
|
describe 'the second item' do
|
147
154
|
subject { apps_dir }
|
148
155
|
|
@@ -150,6 +157,7 @@ describe BrowseEverything::Driver::Box, vcr: { cassette_name: 'box', record: :no
|
|
150
157
|
its(:id) { is_expected.to eq('2459974427') }
|
151
158
|
it { is_expected.to be_container }
|
152
159
|
end
|
160
|
+
|
153
161
|
describe 'a file' do
|
154
162
|
subject { equipment }
|
155
163
|
|
@@ -38,12 +38,14 @@ describe BrowseEverything::Driver::FileSystem do
|
|
38
38
|
its(:name) { is_expected.to eq('dir_1') }
|
39
39
|
specify { is_expected.to be_container }
|
40
40
|
end
|
41
|
+
|
41
42
|
context 'when there are multiple directories' do
|
42
43
|
subject { contents[1] }
|
43
44
|
|
44
45
|
its(:name) { is_expected.to eq('dir_2') }
|
45
46
|
specify { is_expected.to be_container }
|
46
47
|
end
|
48
|
+
|
47
49
|
context 'when there is a PDF' do
|
48
50
|
subject { contents[2] }
|
49
51
|
|
@@ -64,6 +66,7 @@ describe BrowseEverything::Driver::FileSystem do
|
|
64
66
|
its(:name) { is_expected.to eq('dir_3') }
|
65
67
|
specify { is_expected.to be_container }
|
66
68
|
end
|
69
|
+
|
67
70
|
context 'when there is a text file' do
|
68
71
|
subject { contents.last }
|
69
72
|
|
@@ -67,6 +67,7 @@ describe BrowseEverything::Driver::S3 do
|
|
67
67
|
its(:name) { is_expected.to eq('bar') }
|
68
68
|
specify { is_expected.to be_container }
|
69
69
|
end
|
70
|
+
|
70
71
|
context 'with two assets' do
|
71
72
|
subject { contents[1] }
|
72
73
|
|
@@ -100,6 +101,7 @@ describe BrowseEverything::Driver::S3 do
|
|
100
101
|
its(:name) { is_expected.to eq('..') }
|
101
102
|
specify { is_expected.to be_container }
|
102
103
|
end
|
104
|
+
|
103
105
|
context 'with a JPEG asset' do
|
104
106
|
subject { contents[1] }
|
105
107
|
|
@@ -109,6 +111,7 @@ describe BrowseEverything::Driver::S3 do
|
|
109
111
|
its(:size) { is_expected.to eq(52645) }
|
110
112
|
specify { is_expected.not_to be_container }
|
111
113
|
end
|
114
|
+
|
112
115
|
context 'with a PNG asset' do
|
113
116
|
subject { contents[2] }
|
114
117
|
|
@@ -133,17 +136,17 @@ describe BrowseEverything::Driver::S3 do
|
|
133
136
|
|
134
137
|
it ':signed_url' do
|
135
138
|
provider.config[:response_type] = :signed_url
|
136
|
-
expect(provider.link_for('foo/quux.png')).to eq [
|
139
|
+
expect(provider.link_for('foo/quux.png')).to eq ['https://s3.amazonaws.com/presigned_url', { file_name: 'quux.png', expires: 14400 }]
|
137
140
|
end
|
138
141
|
|
139
142
|
it ':public_url' do
|
140
143
|
provider.config[:response_type] = :public_url
|
141
|
-
expect(provider.link_for('foo/quux.png')).to eq [
|
144
|
+
expect(provider.link_for('foo/quux.png')).to eq ['https://s3.amazonaws.com/public_url', { file_name: 'quux.png' }]
|
142
145
|
end
|
143
146
|
|
144
147
|
it ':s3_uri' do
|
145
148
|
provider.config[:response_type] = :s3_uri
|
146
|
-
expect(provider.link_for('foo/quux.png')).to eq ['s3://s3.bucket/foo/quux.png', {:
|
149
|
+
expect(provider.link_for('foo/quux.png')).to eq ['s3://s3.bucket/foo/quux.png', { file_name: 'quux.png' }]
|
147
150
|
end
|
148
151
|
end
|
149
152
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe BrowseEverything::Driver do
|
4
|
-
|
5
4
|
let(:my_driver) do
|
6
5
|
MyDriver.new
|
7
6
|
end
|
@@ -10,7 +9,7 @@ describe BrowseEverything::Driver do
|
|
10
9
|
class MyDriver
|
11
10
|
include BrowseEverything::Driver
|
12
11
|
|
13
|
-
def get_sorter
|
12
|
+
def get_sorter # rubocop:disable Naming/AccessorMethodName
|
14
13
|
sorter
|
15
14
|
end
|
16
15
|
end
|
@@ -18,17 +17,17 @@ describe BrowseEverything::Driver do
|
|
18
17
|
|
19
18
|
describe '#sorter' do
|
20
19
|
it 'defaults to nil' do
|
21
|
-
expect(
|
20
|
+
expect(described_class.sorter).to be nil
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
describe '#sorter=' do
|
26
25
|
let(:new_sorter) do
|
27
|
-
|
26
|
+
->(files) {}
|
28
27
|
end
|
29
28
|
|
30
29
|
before do
|
31
|
-
|
30
|
+
described_class.sorter = new_sorter
|
32
31
|
end
|
33
32
|
|
34
33
|
it 'mutates the sorter from the initializer' do
|
@@ -9,7 +9,8 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
9
9
|
let(:size) { File.size(datafile) }
|
10
10
|
|
11
11
|
describe '#get_file_size' do
|
12
|
-
subject(:
|
12
|
+
subject(:computed_file_size) { retriever.file_size(options) }
|
13
|
+
|
13
14
|
let(:url) { URI.parse("file://#{datafile}") }
|
14
15
|
let(:headers) { [] }
|
15
16
|
let(:file_size) { 0 }
|
@@ -22,26 +23,26 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'calculates or retrieves the size of a file' do
|
25
|
-
retriever.retrieve(options) do |
|
26
|
+
retriever.retrieve(options) do |_chunk, _retrieved, total|
|
26
27
|
expect(total).to eq 2256
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
context
|
31
|
-
let(:url) { URI.parse(
|
31
|
+
context 'when retrieving a resource from a cloud storage provider' do
|
32
|
+
let(:url) { URI.parse('https://drive.google.com/uc?id=id&export=download') }
|
32
33
|
|
33
34
|
it 'calculates or retrieves the size of a file' do
|
34
|
-
retriever.retrieve(options) do |
|
35
|
+
retriever.retrieve(options) do |_chunk, _retrieved, total|
|
35
36
|
expect(total).to eq 1234
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
context
|
41
|
-
let(:url) { URI.parse(
|
41
|
+
context 'when retrieving a resource with an unsupported protocol' do
|
42
|
+
let(:url) { URI.parse('ftp://invalid') }
|
42
43
|
|
43
|
-
it
|
44
|
-
expect { retriever.retrieve(options) {|c, r, t|} }.to raise_error(URI::BadURIError,
|
44
|
+
it 'raises an error' do
|
45
|
+
expect { retriever.retrieve(options) { |c, r, t| } }.to raise_error(URI::BadURIError, 'Unknown URI scheme: ftp')
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -167,7 +168,7 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
170
|
-
|
171
|
+
describe '.can_retrieve?' do
|
171
172
|
let(:expiry_time) { (Time.current + 3600).xmlschema }
|
172
173
|
let(:spec) do
|
173
174
|
{
|
@@ -181,19 +182,19 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
181
182
|
}
|
182
183
|
end
|
183
184
|
|
184
|
-
context 'can retrieve' do
|
185
|
+
context 'when can retrieve' do
|
185
186
|
let(:url) { 'https://retrieve.cloud.example.com/some/dir/can_retrieve.pdf' }
|
186
187
|
|
187
188
|
it 'says it can' do
|
188
|
-
expect(described_class.
|
189
|
+
expect(described_class).to be_can_retrieve(url)
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
192
|
-
context 'cannot retrieve' do
|
193
|
+
context 'when cannot retrieve' do
|
193
194
|
let(:url) { 'https://retrieve.cloud.example.com/some/dir/cannot_retrieve.pdf' }
|
194
195
|
|
195
196
|
it 'says it cannot' do
|
196
|
-
expect(described_class.
|
197
|
+
expect(described_class).not_to be_can_retrieve(url)
|
197
198
|
end
|
198
199
|
end
|
199
200
|
end
|
@@ -1,59 +1,76 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe BrowseEverything do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
dropbox: {
|
9
|
-
app_key: 'test-key',
|
10
|
-
app_secret: 'test-secret'
|
11
|
-
},
|
12
|
-
box: {
|
13
|
-
client_id: 'test-id',
|
14
|
-
client_secret: 'test-secret'
|
15
|
-
},
|
16
|
-
google_drive: {
|
17
|
-
client_id: 'test-id',
|
18
|
-
client_secret: 'test-secret'
|
19
|
-
}
|
20
|
-
}
|
21
|
-
end
|
22
|
-
before do
|
23
|
-
BrowseEverything.configure(config)
|
24
|
-
end
|
25
|
-
it 'registers the configuration for the drivers' do
|
26
|
-
expect(BrowseEverything.config).to be_a ActiveSupport::HashWithIndifferentAccess
|
4
|
+
shared_examples "a configured BrowseEverything module" do
|
5
|
+
describe 'registered configuration' do
|
6
|
+
it 'registers the configuration for the drivers' do
|
7
|
+
expect(described_class.config).to be_a ActiveSupport::HashWithIndifferentAccess
|
27
8
|
|
28
|
-
|
29
|
-
|
30
|
-
|
9
|
+
expect(described_class.config).to include 'dropbox'
|
10
|
+
expect(described_class.config['dropbox']).to include('app_key' => 'test-key')
|
11
|
+
expect(described_class.config['dropbox']).to include('app_secret' => 'test-secret')
|
31
12
|
|
32
|
-
|
33
|
-
|
34
|
-
|
13
|
+
expect(described_class.config).to include 'box'
|
14
|
+
expect(described_class.config['box']).to include('client_id' => 'test-id')
|
15
|
+
expect(described_class.config['box']).to include('client_secret' => 'test-secret')
|
35
16
|
|
36
|
-
|
37
|
-
|
38
|
-
|
17
|
+
expect(described_class.config).to include 'google_drive'
|
18
|
+
expect(described_class.config['google_drive']).to include('client_id' => 'test-id')
|
19
|
+
expect(described_class.config['google_drive']).to include('client_secret' => 'test-secret')
|
20
|
+
end
|
39
21
|
end
|
22
|
+
end
|
40
23
|
|
41
|
-
|
24
|
+
describe '.configure' do
|
25
|
+
context 'with a hash' do
|
42
26
|
let(:config) do
|
43
27
|
{
|
44
|
-
|
28
|
+
dropbox: {
|
45
29
|
app_key: 'test-key',
|
46
30
|
app_secret: 'test-secret'
|
31
|
+
},
|
32
|
+
box: {
|
33
|
+
client_id: 'test-id',
|
34
|
+
client_secret: 'test-secret'
|
35
|
+
},
|
36
|
+
google_drive: {
|
37
|
+
client_id: 'test-id',
|
38
|
+
client_secret: 'test-secret'
|
47
39
|
}
|
48
40
|
}
|
49
41
|
end
|
50
42
|
|
51
|
-
|
52
|
-
|
53
|
-
expect(BrowseEverything.config).to include 'dropbox'
|
54
|
-
expect(BrowseEverything.config['dropbox']).to include({ 'app_key' => 'test-key' })
|
55
|
-
expect(BrowseEverything.config['dropbox']).to include({ 'app_secret' => 'test-secret' })
|
43
|
+
before do
|
44
|
+
described_class.configure(config)
|
56
45
|
end
|
46
|
+
|
47
|
+
it_behaves_like 'a configured BrowseEverything module'
|
48
|
+
|
49
|
+
context 'with an entry for the drop_box provider' do
|
50
|
+
let(:config) do
|
51
|
+
{
|
52
|
+
drop_box: {
|
53
|
+
app_key: 'test-key',
|
54
|
+
app_secret: 'test-secret'
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'logs a deprecation warning and sets it to the dropbox key' do
|
60
|
+
expect(described_class.config).not_to include 'drop_box'
|
61
|
+
expect(described_class.config).to include 'dropbox'
|
62
|
+
expect(described_class.config['dropbox']).to include('app_key' => 'test-key')
|
63
|
+
expect(described_class.config['dropbox']).to include('app_secret' => 'test-secret')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with a YAML file' do
|
69
|
+
before do
|
70
|
+
described_class.configure(File.expand_path('../../fixtures/config/browse_everything_providers.yml', __FILE__))
|
71
|
+
end
|
72
|
+
|
73
|
+
it_behaves_like 'a configured BrowseEverything module'
|
57
74
|
end
|
58
75
|
end
|
59
76
|
|
@@ -61,7 +78,7 @@ describe BrowseEverything do
|
|
61
78
|
let(:config) { 1234 }
|
62
79
|
|
63
80
|
it 'raises an initialization error' do
|
64
|
-
expect {
|
81
|
+
expect { described_class.configure(config) }.to raise_error(BrowseEverything::InitializationError, 'Unrecognized configuration: 1234')
|
65
82
|
end
|
66
83
|
end
|
67
84
|
end
|
@@ -18,6 +18,7 @@ describe BrowseEverythingSession::ProviderSession do
|
|
18
18
|
allow(session).to receive(:[]).and_return('test-token')
|
19
19
|
provider_session.token = 'test-token'
|
20
20
|
end
|
21
|
+
|
21
22
|
it 'sets and accesses the access token' do
|
22
23
|
expect(provider_session.token).to eq 'test-token'
|
23
24
|
expect(session).to have_received(:[]).with('test_session_token')
|
@@ -30,6 +31,7 @@ describe BrowseEverythingSession::ProviderSession do
|
|
30
31
|
allow(session).to receive(:[]).and_return('test-code')
|
31
32
|
provider_session.code = 'test-code'
|
32
33
|
end
|
34
|
+
|
33
35
|
it 'sets and accesses the access code' do
|
34
36
|
expect(provider_session.code).to eq 'test-code'
|
35
37
|
expect(session).to have_received(:[]).with('test_session_code')
|
@@ -42,6 +44,7 @@ describe BrowseEverythingSession::ProviderSession do
|
|
42
44
|
allow(session).to receive(:[]).and_return('test' => 'data')
|
43
45
|
provider_session.data = { 'test' => 'data' }
|
44
46
|
end
|
47
|
+
|
45
48
|
it 'sets and accesses the access data' do
|
46
49
|
expect(provider_session.data).to eq('test' => 'data')
|
47
50
|
expect(session).to have_received(:[]).with('test_session_data')
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
ENV['RAILS_ENV'] ||= 'test'
|
4
|
+
require 'bundler/setup'
|
4
5
|
|
5
6
|
def coverage_needed?
|
6
7
|
ENV['COVERAGE'] || ENV['TRAVIS']
|
@@ -9,7 +10,7 @@ end
|
|
9
10
|
if coverage_needed?
|
10
11
|
require 'simplecov'
|
11
12
|
require 'coveralls'
|
12
|
-
SimpleCov.root(File.expand_path('
|
13
|
+
SimpleCov.root(File.expand_path('..', __dir__))
|
13
14
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
14
15
|
[
|
15
16
|
SimpleCov::Formatter::HTMLFormatter,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
|
5
5
|
class TestAppGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path('
|
6
|
+
source_root File.expand_path('../../../spec/test_app_templates', __dir__)
|
7
7
|
|
8
8
|
def install_engine
|
9
9
|
generate 'browse_everything:install -f'
|
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.16.
|
4
|
+
version: 0.16.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: 2018-
|
16
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: addressable
|
@@ -114,19 +114,19 @@ dependencies:
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '2.1'
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
|
-
name:
|
117
|
+
name: googleauth
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - '='
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
122
|
+
version: 0.6.2
|
123
123
|
type: :runtime
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- -
|
127
|
+
- - '='
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
129
|
+
version: 0.6.2
|
130
130
|
- !ruby/object:Gem::Dependency
|
131
131
|
name: rails
|
132
132
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +197,34 @@ dependencies:
|
|
197
197
|
- - "~>"
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0.20'
|
200
|
+
- !ruby/object:Gem::Dependency
|
201
|
+
name: typhoeus
|
202
|
+
requirement: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
type: :runtime
|
208
|
+
prerelease: false
|
209
|
+
version_requirements: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
- !ruby/object:Gem::Dependency
|
215
|
+
name: bixby
|
216
|
+
requirement: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '1.0'
|
221
|
+
type: :development
|
222
|
+
prerelease: false
|
223
|
+
version_requirements: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - ">="
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '1.0'
|
200
228
|
- !ruby/object:Gem::Dependency
|
201
229
|
name: bundler
|
202
230
|
requirement: !ruby/object:Gem::Requirement
|
@@ -365,34 +393,20 @@ dependencies:
|
|
365
393
|
- - ">="
|
366
394
|
- !ruby/object:Gem::Version
|
367
395
|
version: '0'
|
368
|
-
- !ruby/object:Gem::Dependency
|
369
|
-
name: rubocop
|
370
|
-
requirement: !ruby/object:Gem::Requirement
|
371
|
-
requirements:
|
372
|
-
- - "~>"
|
373
|
-
- !ruby/object:Gem::Version
|
374
|
-
version: '0.53'
|
375
|
-
type: :development
|
376
|
-
prerelease: false
|
377
|
-
version_requirements: !ruby/object:Gem::Requirement
|
378
|
-
requirements:
|
379
|
-
- - "~>"
|
380
|
-
- !ruby/object:Gem::Version
|
381
|
-
version: '0.53'
|
382
396
|
- !ruby/object:Gem::Dependency
|
383
397
|
name: rubocop-rspec
|
384
398
|
requirement: !ruby/object:Gem::Requirement
|
385
399
|
requirements:
|
386
|
-
- - "
|
400
|
+
- - ">="
|
387
401
|
- !ruby/object:Gem::Version
|
388
|
-
version: '
|
402
|
+
version: '0'
|
389
403
|
type: :development
|
390
404
|
prerelease: false
|
391
405
|
version_requirements: !ruby/object:Gem::Requirement
|
392
406
|
requirements:
|
393
|
-
- - "
|
407
|
+
- - ">="
|
394
408
|
- !ruby/object:Gem::Version
|
395
|
-
version: '
|
409
|
+
version: '0'
|
396
410
|
- !ruby/object:Gem::Dependency
|
397
411
|
name: selenium-webdriver
|
398
412
|
requirement: !ruby/object:Gem::Requirement
|
@@ -532,6 +546,7 @@ files:
|
|
532
546
|
- spec/controllers/browse_everything_controller_spec.rb
|
533
547
|
- spec/features/select_files_spec.rb
|
534
548
|
- spec/features/test_compiling_stylesheets_spec.rb
|
549
|
+
- spec/fixtures/config/browse_everything_providers.yml
|
535
550
|
- spec/fixtures/file_system/dir_1/dir_3/file_3.m4v
|
536
551
|
- spec/fixtures/file_system/dir_1/file_2.txt
|
537
552
|
- spec/fixtures/file_system/dir_2/file_4.docx
|
@@ -604,6 +619,7 @@ test_files:
|
|
604
619
|
- spec/controllers/browse_everything_controller_spec.rb
|
605
620
|
- spec/features/select_files_spec.rb
|
606
621
|
- spec/features/test_compiling_stylesheets_spec.rb
|
622
|
+
- spec/fixtures/config/browse_everything_providers.yml
|
607
623
|
- spec/fixtures/file_system/dir_1/dir_3/file_3.m4v
|
608
624
|
- spec/fixtures/file_system/dir_1/file_2.txt
|
609
625
|
- spec/fixtures/file_system/dir_2/file_4.docx
|