Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
Updating to Ruby 2.5.5
Browse files Browse the repository at this point in the history
Changes:

Cloud providers test now uses Box

Dropbox is no longer supported and the Ruby update was breaking this
test. Instead of fixing a test for an unsupported endpoint, the test was
updated to work against Box.

Removing 'bom|utf-8' encoding from CSV.parse

This is a not a supported encoding type. It's been changed to just
'utf-8' which ought to avoid the problem, but a recent update to CSV has
added support back in. We could possible revert this later with a newer
Ruby if needed.
  • Loading branch information
awead committed May 7, 2019
1 parent 9b80aa1 commit 3eb7e43
Show file tree
Hide file tree
Showing 7 changed files with 462 additions and 592 deletions.
18 changes: 9 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-02-25 13:39:08 -0500 using RuboCop version 0.62.0.
# on 2019-05-07 14:00:27 -0400 using RuboCop version 0.62.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -17,17 +17,17 @@ Lint/UriEscapeUnescape:
- 'app/actors/sufia/create_with_remote_files_actor.rb'
- 'spec/features/authentication_spec.rb'

# Offense count: 224
# Offense count: 227
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 222
Max: 231

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 7

# Offense count: 308
# Offense count: 307
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Expand All @@ -37,11 +37,11 @@ Metrics/LineLength:
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 47
# Offense count: 48
RSpec/AnyInstance:
Enabled: false

# Offense count: 137
# Offense count: 138
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand All @@ -66,13 +66,13 @@ RSpec/ExpectInHook:
- 'spec/features/file_set/analytics_spec.rb'
- 'spec/models/user_spec.rb'

# Offense count: 160
# Offense count: 166
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Enabled: false

# Offense count: 291
# Offense count: 298
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 58
Expand Down Expand Up @@ -131,7 +131,7 @@ Rails/DynamicFindBy:
- 'app/services/permissions_change_service.rb'
- 'spec/views/curations_concerns/base/_form_relationships.html.erb_spec.rb'

# Offense count: 35
# Offense count: 36
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.3
2.5.5
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cache:
bundler_args: --without development debug
sudo: false
rvm:
- 2.3.3
- 2.5.5
jdk:
- oraclejdk8
env:
Expand Down
6 changes: 5 additions & 1 deletion lib/clean_agents/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ def parse_file(file_name)
parse_csv(lines)
end

# @note Encoding was updated to just 'utf-8' but it shouldn't be a problem since 'bom|utf-8'
# is applied to the file above in {parse_file}.
# However, it could be added back here with a later Ruby upgrade that
# includes this: https://github.com/ruby/csv/pull/24
def parse_csv(csv)
data = CSV.parse(csv, headers: true, encoding: 'bom|utf-8')
data = CSV.parse(csv, headers: true, encoding: 'utf-8')
{ split_groups: CleanAgents::SplitProcessor.find_split_groups(data),
combine_groups: CleanAgents::CombineProcessor.find_combine_groups(data),
file_data: data }
Expand Down
63 changes: 46 additions & 17 deletions spec/features/generic_work/upload_and_delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,32 @@

context 'cloud providers' do
before do
allow(BrowseEverything).to receive(:config) { { 'dropbox' => { app_key: 'fakekey189274942347', app_secret: 'fakesecret489289472347298', max_upload_file_size: 20 * 1024 } } }
allow(Sufia.config).to receive(:browse_everything).and_return('dropbox' => { app_key: 'fakekey189274942347', app_secret: 'fakesecret489289472347298' })
allow_any_instance_of(BrowseEverything::Driver::Dropbox).to receive(:authorized?).and_return(true)
allow_any_instance_of(BrowseEverything::Driver::Dropbox).to receive(:token).and_return('FakeDropboxAccessToken01234567890ABCDEF_AAAAAAA987654321')
allow(BrowseEverything).to receive(:config) do
{
'box' => {
client_id: 'fake-box-client-id',
client_secret: 'fake-box-client-secret',
max_upload_file_size: 25 * 1024
}
}
end

allow(Sufia.config).to receive(:browse_everything) .and_return(
'dropbox' => {
client_id: 'fake-box-client-id',
client_secret: 'fake-box-client-secret'
}
)

allow_any_instance_of(BrowseEverything::Driver::Box)
.to receive(:box_token)
.and_return('FAKEBOXTOKEN')

allow_any_instance_of(BrowseEverything::Driver::Box)
.to receive(:box_refresh_token)
.and_return('FAKEBOXREFRESHTOKEN')

allow_any_instance_of(BrowseEverything::Driver::Box).to receive(:authorized?).and_return(true)
allow_any_instance_of(GenericWork).to receive(:share_notified?).and_return(false)
WebMock.enable!
end
Expand All @@ -53,32 +75,39 @@

specify 'I can click on cloud providers' do
expect(ShareNotifyJob).to receive(:perform_later)
VCR.use_cassette('dropbox', record: :none) do
VCR.use_cassette('box', record: :none) do
click_link 'Files'
expect(page).to have_content 'Add cloud files'
click_on 'Add cloud files'
expect(page).to have_css '#provider-select'
select 'Dropbox', from: 'provider-select'

# Choose Box and view the files
select 'Box', from: 'provider-select'
sleep(1.second)
expect(page).to have_content 'Getting Started.pdf'
click_on('Writer')
expect(page).to have_content 'My Box Notes'
expect(page).to have_content 'Box-upload-test.boxnote'
expect(page).to have_content 'creators.m4v'

# Files above the size limit are not clickable
expect(page).not_to have_css 'a', text: 'creators.m4v'

# Upload file into the queue
click_on('Box-upload-test.boxnote')
sleep(1.second)
expect(page).to have_content 'Writer FAQ.txt'
expect(page).not_to have_css 'a', text: 'Writer FAQ.txt'
expect(page).to have_content 'Markdown Test.txt'
check('writer-markdown-test-txt')
expect(page).to have_content '1 file selected'
click_on('Submit')
within 'tr.template-download' do
expect(page).to have_content 'Markdown Test.txt'
expect(page).to have_content 'Box-upload-test.boxnote'
end
within('#savewidget') do
choose 'generic_work_visibility_authenticated'
end
sleep(1.second)

# Fill in the rest of the metadata and create the work
check 'agreement'
click_on 'Metadata'
fill_in 'generic_work_title', with: 'Markdown Test'
fill_in 'generic_work_title', with: 'Box Upload Test'
fill_in 'generic_work_keyword', with: 'keyword'
fill_in 'generic_work[creators][0][given_name]', with: 'creator'
select 'Attribution-NonCommercial-NoDerivatives 4.0 International', from: 'generic_work_rights'
Expand All @@ -88,11 +117,11 @@
click_on 'Save'
expect(page).to have_content 'Your files are being processed'
within('#activity_log') do
expect(page).to have_content("User #{current_user.display_name} has deposited Markdown Test")
expect(page).to have_content("User #{current_user.display_name} has deposited Box Upload Test")
end
expect(page).to have_css('h1', text: 'Markdown Test')
expect(page).to have_css('h1', text: 'Box Upload Test')
click_on 'Notifications'
expect(page).to have_content 'The file (Markdown Test.txt) was successfully imported'
expect(page).to have_content 'The file (Box-upload-test.boxnote) was successfully imported'
end
end
end
Expand Down
Loading

0 comments on commit 3eb7e43

Please sign in to comment.