Skip to content

Commit

Permalink
Merge of master and fixes for chrome 74 problems and update to webdri…
Browse files Browse the repository at this point in the history
…vers.
  • Loading branch information
sfisher committed May 8, 2019
2 parents 099d986 + 4e89ffc commit 8918a37
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ before_script:
# To allow travis to run chrome we need to force chromedriver to use a specific version
# since Chrome and Chromedriver versions must match :/
# There is an open ticket on chromedriver -> https://github.com/flavorjones/chromedriver-helper/issues/78
- bundle exec chromedriver-update 2.46
# - bundle exec chromedriver-update 2.46
- sudo chown root /opt/google/chrome/chrome-sandbox
- sudo chmod 4755 /opt/google/chrome/chrome-sandbox
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ group :test do
gem 'capybara'
# Automatically create snapshots when Cucumber steps fail with Capybara and Rails (http://github.com/mattheworiordan/capybara-screenshot)
gem 'capybara-screenshot'
# chromedriver-helper is now deprecated, use webdriver instead
# Easy installation and use of chromedriver. (https://github.com/flavorjones/chromedriver-helper)
# gem 'chromedriver-helper', '>= 1.2'
# chromedriver-helper is now deprecated, use webdrivers instead
gem 'webdrivers'
# Strategies for cleaning databases. Can be used to ensure a clean state for testing. (http://github.com/DatabaseCleaner/database_cleaner)
gem 'database_cleaner', require: false
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ------------------------------------------------------------
# Rails defaults

require File.expand_path('../config/application', __FILE__)
require File.expand_path('config/application', __dir__)
Rails.application.load_tasks

# ------------------------------------------------------------
Expand Down
37 changes: 37 additions & 0 deletions spec/features/stash_datacite/new_dataset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,43 @@
fill_in 'related_identifier[related_identifier]', with: Faker::Pid.doi
end

it 'charges user by default', js: true do
navigate_to_review
expect(page).to have_text('you will receive an invoice')
end

it 'waives the fee when institution is in a fee-waiver country', js: true do
waiver_country = Faker::Address.country
waiver_university = Faker::Educator.university
stub_ror_id_lookup(university: waiver_university, country: waiver_country)
allow_any_instance_of(StashDatacite::Affiliation).to receive(:fee_waiver_countries).and_return([waiver_country])

# ##############################
# Author w/ affiliation in specific university
fill_in_author
fill_in 'author[affiliation][long_name]', with: waiver_university
first('.ui-menu-item-wrapper', wait: 5).click

navigate_to_review
expect(page).to have_text('Payment is not required', wait: 5)
end

it 'charges user when institution is not in a fee-waiver country', js: true do
non_waiver_country = Faker::Address.country
non_waiver_university = Faker::Educator.university
stub_ror_id_lookup(university: non_waiver_university, country: non_waiver_country)
allow_any_instance_of(StashDatacite::Affiliation).to receive(:fee_waiver_countries).and_return(['Waiverlandia'])

# ##############################
# Author w/ affiliation in specific university
fill_in_author
fill_in 'author[affiliation][long_name]', with: non_waiver_university
first('.ui-menu-item-wrapper', wait: 5).click

navigate_to_review
expect(page).to have_text('you will receive an invoice', wait: 5)
end

end

end
Expand Down
2 changes: 0 additions & 2 deletions spec/features/stash_discovery/solr_sanitization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
before(:all) do
# Start Solr - shutdown is handled globally when all tests have finished
# SolrInstance.instance

# rubocop:disable Security/YAMLLoad
# doc = YAML.load(ERB.new(File.read(File.join(Rails.root, SolrInstance::BLACKLIGHT_YML))).result)
# rubocop:enable Security/YAMLLoad
# @solr = RSolr.connect(url: doc['test']['url'])
Expand Down
12 changes: 6 additions & 6 deletions spec/mocks/ror.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def mock_ror!
end

# rubocop:disable Metrics/MethodLength
def stub_ror_id_lookup
def stub_ror_id_lookup(university: 'University of Testing', country: 'United States of America')
# Mock a request for a specific ROR Organization
stub_request(:get, %r{api\.ror\.org/organizations/.+})
.with(
Expand All @@ -17,14 +17,14 @@ def stub_ror_id_lookup
}
).to_return(status: 200, body: {
'id': 'https://ror.org/TEST',
'name': 'University of Testing',
'name': university,
'types': ['Education'],
'links': ['http://example.org/test'],
'aliases': ['testing'],
'acronyms': ['TST'],
'wikipedia_url': 'http://example.org/wikipedia/wiki/test',
'labels': [{ 'iso639': 'id', 'label': 'University of Testing' }],
'country': { 'code': 'US', 'name': 'United States of America' },
'labels': [{ 'iso639': 'id', 'label': university }],
'country': { 'country_code': 'US', 'country_name': country },
'external_ids': { 'GRID': { 'prefered': 'grid.test.123' } }
}.to_json, headers: { 'Content-Type' => 'application/json' })
end
Expand All @@ -49,7 +49,7 @@ def stub_ror_name_lookup
'acronyms': ['TST'],
'wikipedia_url': 'http://example.org/wikipedia/wiki/test',
'labels': [{ 'iso639': 'id', 'label': 'University of Testing' }],
'country': { 'code': 'US', 'name': 'United States of America' },
'country': { 'country_code': 'US', 'country_name': 'United States of America' },
'external_ids': { 'GRID': { 'prefered': 'grid.test.123' } }
},
{
Expand All @@ -61,7 +61,7 @@ def stub_ror_name_lookup
'acronyms': ['TST2'],
'wikipedia_url': 'http://example.org/wikipedia/wiki/test2',
'labels': [{ 'iso639': 'id', 'label': 'University of Testing v2' }],
'country': { 'code': 'US', 'name': 'United States of America' },
'country': { 'country_code': 'US', 'country_name': 'United States of America' },
'external_ids': { 'GRID': { 'prefered': 'grid.test.123v2' } }
}
]
Expand Down
5 changes: 3 additions & 2 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
Webdrivers.install_dir = '~/.webdrivers'
# Selenium::WebDriver::Chrome.path = '~/.webdrivers/chromedriver'


# This is a customisation of the default :selenium_chrome_headless config in:
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara.rb
#
# This adds the --no-sandbox flag to fix TravisCI as described here:
# https://docs.travis-ci.com/user/chrome#sandboxing

Capybara.register_driver :selenium_chrome_headless do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
Capybara::Selenium::Driver.new(app, browser: :chrome)
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--incognito'
Expand All @@ -41,6 +40,8 @@
browser_options.args << '--disable-infobars'
browser_options.args << '--disable-extensions'
browser_options.args << '--disable-popup-blocking'
browser_options.args << '--disable-gpu' if Gem.win_platform?
browser_options.args << '--enable-features=NetworkService,NetworkServiceInProcess'

# chromeOptions.AddAdditionalCapability("acceptInsecureCerts", true, true);
browser_options.args << '--disable-gpu' if Gem.win_platform?
Expand Down
1 change: 1 addition & 0 deletions spec/support/helpers/dataset_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def fill_in_author
def agree_to_everything
navigate_to_review
find('#agree_to_license').click
find('#agree_to_tos').click
find('#agree_to_payment').click
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/web_driver_fix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def delete_all_cookies
end
end
end
end
end

0 comments on commit 8918a37

Please sign in to comment.