Merge pull request #2659 from AndrewKvalheim/transactional-tests
Use Rails transactional tests
This commit is contained in:
commit
0729c6f6fe
8 changed files with 4 additions and 39 deletions
|
|
@ -85,7 +85,6 @@ feature Commercial do
|
|||
click_button 'Update'
|
||||
page.find('#flash')
|
||||
expect(flash).to eq('Commercial was 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')
|
||||
|
|
@ -118,7 +117,6 @@ feature Commercial do
|
|||
end
|
||||
page.find('#flash')
|
||||
expect(flash).to eq('Commercial was successfully destroyed.')
|
||||
TransactionalCapybara::AjaxHelpers.wait_for_ajax(page)
|
||||
expect(event.commercials.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -138,7 +138,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
|
||||
|
|
|
|||
|
|
@ -392,7 +392,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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue