Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure database cleaning is very last in each spec #9

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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