Skip to content

Commit

Permalink
Merge pull request #9 from jhawthorn/prepend_and_append_database_cleaner
Browse files Browse the repository at this point in the history
Ensure database cleaning is very last in each spec
  • Loading branch information
jhawthorn authored Feb 22, 2018
2 parents ab094be + 01f549f commit 1302c9b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/solidus_support/extension/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@

config.include Spree::TestingSupport::Preferences

# Ensure Suite is set to use transactions for speed.
config.before :suite do
DatabaseCleaner.clean_with :truncation
end

# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
config.before :each do
# Around each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
config.around(:each) do |example|
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start

reset_spree_preferences
end
DatabaseCleaner.cleaning do
reset_spree_preferences

# After each spec clean the database.
config.after :each do
DatabaseCleaner.clean
example.run
end
end
end

0 comments on commit 1302c9b

Please sign in to comment.