Merge some contributor fixes

This commit is contained in:
Michael Ball 2020-06-30 00:48:47 -07:00
commit 0877aadb2e
72 changed files with 225 additions and 206 deletions

View file

@ -59,6 +59,17 @@ FactoryBot.define do
biography { '<div id="divInjectedElement"></div>' }
end
factory :organization_admin, parent: :user do
transient do
organization { create(:organization) }
end
after(:create) do |user, evaluator|
user.roles << Role.find_or_create_by(name: 'organization_admin', resource: evaluator.organization)
user.save!
end
end
factory :organizer, parent: :user do
transient do
resource { create(:resource) }

View file

@ -75,7 +75,7 @@ feature Commercial do
expect(page).to have_css("button[type='submit']:disabled", text: 'Save Materials')
end
scenario 'updates a commercial of an event', feature: true, js: true do
scenario 'updates materials of an event', feature: true, js: true do
commercial = create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')
@ -85,7 +85,6 @@ feature Commercial do
click_button 'Update'
page.find('#flash')
expect(flash).to eq('Materials were successfully updated.')
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
expect(event.commercials.count).to eq(1)
commercial.reload
expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw')
@ -117,8 +116,7 @@ feature Commercial do
click_link 'Delete'
end
page.find('#flash')
expect(flash).to eq('Materials were successfully destroyed.')
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
expect(flash).to eq('Materials successfully destroyed.')
expect(event.commercials.count).to eq(0)
end
end

View file

@ -114,9 +114,12 @@ feature Event do
visit conference_program_proposals_path(conference.short_title)
click_link 'New Proposal'
expect(page).to have_selector(".in[id='#{find_field('event[event_type_id]').value}-help']") # End of animation
fill_in 'event_title', with: 'Example Proposal'
select('Example Event Type', from: 'event[event_type_id]')
expect(page).to have_selector(".in[id='#{find_field('event[event_type_id]').value}-help']") # End of animation
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
expect(page).to have_text('You have used 3 words')
@ -127,7 +130,6 @@ feature Event do
page.find('#flash')
expect(page).to have_content 'Proposal was successfully submitted.'
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
expect(current_path).to eq(conference_program_proposals_path(conference.short_title))
expect(Event.count).to eq(expected_count)
end

View file

@ -318,17 +318,14 @@ feature 'Version' do
end
context 'organization role', feature: true, versioning: true, js: true do
let!(:organization_admin) { create(:organization_admin, organization: conference.organization) }
let!(:user) { create(:user) }
let!(:role) do
Role.find_by(
resource_id: conference.organization.id,
resource_type: 'Organization'
)
end
setup do
user.add_role :organization_admin, conference.organization
user.remove_role :organization_admin, conference.organization
sign_in organization_admin
visit admin_revision_history_path
end
@ -392,7 +389,7 @@ feature 'Version' do
click_link 'Comments (0)'
fill_in 'comment_body', with: 'Sample comment'
click_button 'Add Comment'
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
expect(page).to have_text('Comments (1)')
Comment.last.destroy
PaperTrail::Version.last.reify.save

View file

@ -20,9 +20,6 @@ require 'webdrivers'
# all migrations applied
ActiveRecord::Migration.maintain_test_schema!
# Keep capybara and the database on the same page
require 'transactional_capybara/rspec'
# Adds rspec helper provided by paper_trail
# makes it easier to control when PaperTrail is enabled during testing.
require 'paper_trail/frameworks/rspec'
@ -49,10 +46,8 @@ RSpec.configure do |config|
# config.mock_with :flexmock
# config.mock_with :rr
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
# Test within database transactions
config.use_transactional_examples = true
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
@ -78,12 +73,10 @@ RSpec.configure do |config|
end
Capybara.register_driver :chrome_headless do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu window-size=1920x1080 no-sandbox) }
)
Capybara::Selenium::Driver.new(
app, browser: :chrome, desired_capabilities: capabilities
options = Selenium::WebDriver::Chrome::Options.new(
args: %w(headless disable-gpu window-size=1920x1080 no-sandbox)
)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
Capybara.default_max_wait_time = 10 # seconds

View file

@ -2,16 +2,7 @@
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:transaction)
DatabaseCleaner.clean_with(:truncation)
Rails.application.load_seed
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do |example|
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page) if example.metadata[:js]
DatabaseCleaner.clean
end
end

View file

@ -2,7 +2,10 @@
# Mock external requests to youtube
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true, allow: /stripe.com/)
driver_urls = Webdrivers::Common.subclasses.map do |driver|
Addressable::URI.parse(driver.base_url).host
end
WebMock.disable_net_connect!(allow_localhost: true, allow: [*driver_urls, /stripe.com/])
RSpec.configure do |config|
config.before(:each) do

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
module ActiveRecord
class Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

View file

@ -9,7 +9,7 @@ RSpec.configure do |config|
example_filename += '.html'
if RSpec.current_example.exception.present?
save_page(example_filename)
save_page(example_screenshotname)
save_screenshot(example_screenshotname) # rubocop:disable Lint/Debugger
# remove the file if the test starts working again
else
File.unlink(example_filename) if File.exist?(example_filename)