Skip to content

Commit

Permalink
Use around hook for DatabaseCleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Feb 22, 2018
1 parent ab094be commit 01f549f
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 01f549f

Please sign in to comment.