Use Rails transactional tests

As of Rails 5.1:

  - Rails has built-in support for running tests within database
    transactions, so Database Cleaner is no longer needed for this.
  - Rails automatically shares the database connection across threads,
    so transactional_capybara is no longer needed.

Changes:

  - Enable `use_transactional_tests`.
  - Remove transactional_capybara.
  - Remove the Database Cleaner test wrapper.

This resolves:

  - transactional_capybara mismanages the shared database connection,
    causing the connection to falsely report as idle after the first
    test. At 6 minutes (idle_timeout + reaping_frequency) into testing,
    the connection is closed, causing e.g. `PG::ConnectionBad` errors.
This commit is contained in:
Andrew Kvalheim 2020-04-05 12:51:30 -07:00 committed by Henne Vogelsang
parent 310fc8dc68
commit c3e02c20b9
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0
7 changed files with 3 additions and 24 deletions

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