mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Bring all Rspec config for database cleaning together
This commit is contained in:
@@ -57,6 +57,24 @@ RSpec.configure do |config|
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# 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.
|
||||
#
|
||||
# Setting this to true keeps the database clean by rolling back any changes.
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
# Some tests don't work within a transaction. Then we use DatabaseCleaner.
|
||||
config.before(:each, concurrency: true) do
|
||||
config.use_transactional_fixtures = false
|
||||
DatabaseCleaner.strategy = :deletion, { except: ['spree_countries', 'spree_states'] }
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
config.after(:each, concurrency: true) do
|
||||
DatabaseCleaner.clean
|
||||
config.use_transactional_fixtures = true
|
||||
end
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
|
||||
@@ -4,17 +4,6 @@ require 'base_spec_helper'
|
||||
require 'database_cleaner'
|
||||
|
||||
RSpec.configure do |config|
|
||||
# DatabaseCleaner
|
||||
config.before(:each, concurrency: true) do
|
||||
config.use_transactional_fixtures = false
|
||||
DatabaseCleaner.strategy = :deletion, { except: ['spree_countries', 'spree_states'] }
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
config.after(:each, concurrency: true) do
|
||||
DatabaseCleaner.clean
|
||||
config.use_transactional_fixtures = true
|
||||
end
|
||||
|
||||
# Precompile Webpacker assets (once) when starting the suite. The default setup can result
|
||||
# in the assets getting compiled many times throughout the build, slowing it down.
|
||||
config.before :suite do
|
||||
@@ -24,11 +13,6 @@ RSpec.configure do |config|
|
||||
# Fix encoding issue in Rails 5.0; allows passing empty arrays or hashes as params.
|
||||
config.before(:each, type: :controller) { @request.env["CONTENT_TYPE"] = 'application/json' }
|
||||
|
||||
# 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 = true
|
||||
|
||||
# You can use `rspec -n` to run only failed specs.
|
||||
config.example_status_persistence_file_path = "tmp/rspec-status.txt"
|
||||
end
|
||||
|
||||
@@ -33,9 +33,6 @@ RSpec.configure do |config|
|
||||
|
||||
config.prepend_before(:each, type: :system) { driven_by :cuprite }
|
||||
|
||||
# System tests use transactional fixtures instead of DatabaseCleaner
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
# Make sure url helpers in mailers use the Capybara server host.
|
||||
config.around(:each, type: :system) do |example|
|
||||
original_host = Rails.application.default_url_options[:host]
|
||||
|
||||
Reference in New Issue
Block a user