diff --git a/Gemfile b/Gemfile index 3d01bbee6..2402bb94a 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,6 @@ end group :test do gem 'capybara' - gem 'database_cleaner' gem 'factory_bot_rails' gem 'pundit-matchers' gem 'rails-controller-testing' diff --git a/Gemfile.lock b/Gemfile.lock index e0aab97d5..42065148a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -136,12 +136,6 @@ GEM csv (3.3.0) dachsfisch (1.0.0) nokogiri (>= 1.14.1, < 2.0.0) - database_cleaner (2.0.2) - database_cleaner-active_record (>= 2, < 3) - database_cleaner-active_record (2.2.0) - activerecord (>= 5.a) - database_cleaner-core (~> 2.0.0) - database_cleaner-core (2.0.1) date (3.3.4) debug_inspector (1.2.0) deep_merge (1.2.2) @@ -608,7 +602,6 @@ DEPENDENCIES capybara coffee-rails config - database_cleaner devise (~> 4.9) devise-bootstrap-views factory_bot_rails diff --git a/spec/db/seeds_spec.rb b/spec/db/seeds_spec.rb index 5b64746cd..cf5f6e960 100644 --- a/spec/db/seeds_spec.rb +++ b/spec/db/seeds_spec.rb @@ -14,16 +14,14 @@ Rake::Task['db:migrate'].invoke # We want to execute the seeds for the dev environment against the test database - # rubocop:disable Rails/Inquiry - allow(Rails).to receive(:env) { 'development'.inquiry } - # rubocop:enable Rails/Inquiry + allow(Rails).to receive(:env) { 'development'.inquiry } # rubocop:disable Rails/Inquiry allow(ActiveRecord::Base).to receive(:establish_connection).and_call_original allow(ActiveRecord::Base).to receive(:establish_connection).with(:development) { ActiveRecord::Base.establish_connection(:test) } end - describe 'execute db:seed', cleaning_strategy: :truncation do + describe 'execute db:seed' do it 'collects the test results' do expect { seed }.not_to raise_error end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 03fd022c3..30a83c3a8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -42,7 +42,7 @@ # 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 + config.use_transactional_fixtures = true # You can uncomment this line to turn off ActiveRecord support entirely. # config.use_active_record = false diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb deleted file mode 100644 index 5efe0eb40..000000000 --- a/spec/support/database_cleaner.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require 'capybara/rspec' - -RSpec.configure do |config| - config.use_transactional_fixtures = false - - config.before(:suite) do - if config.use_transactional_fixtures? - raise(<<-MSG) - Delete line `config.use_transactional_fixtures = true` from rails_helper.rb - (or set it to false) to prevent uncommitted transactions being used in - JavaScript-dependent specs. - - During testing, the app-under-test that the browser driver connects to - uses a different database connection to the database connection used by - the spec. The app's database connection would not be able to access - uncommitted transaction data setup over the spec's database connection. - MSG - end - - DatabaseCleaner.clean_with(:truncation) - end - - config.before do |example| - DatabaseCleaner.strategy = example.metadata[:cleaning_strategy] || :transaction - end - - config.before(:each, type: :system) do - # :rack_test driver's Rack app under test shares database connection - # with the specs, so continue to use transaction strategy for speed. - unless Capybara.current_driver == :rack_test - # Driver is probably for an external browser with an app - # under test that does *not* share a database connection with the - # specs, so use truncation strategy. - DatabaseCleaner.strategy = :truncation - end - end - - config.before do - DatabaseCleaner.start - end - - config.append_after do - DatabaseCleaner.clean - end -end