mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-20 14:04:21 -04:00
Fix database connection to share with capybara
and the database cleaner to use transactions, not truncation
This commit is contained in:
1 parent
cb1dcc9f8f
commit
45ba712eb7
1 file changed
+19
-17
@@ -1,6 +1,5 @@
|
||||
RSpec.configure do |config|
|
||||
|
||||
# database cleaner warning if you turn this off
|
||||
# a warning if you turn this off
|
||||
config.before(:suite) do
|
||||
if config.use_transactional_fixtures?
|
||||
raise(<<-MSG)
|
||||
@@ -17,26 +16,29 @@ RSpec.configure do |config|
|
||||
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
# config.before(:suite) do
|
||||
# DatabaseCleaner.clean_with(:truncation)
|
||||
# end
|
||||
|
||||
# config.before do
|
||||
# DatabaseCleaner.strategy = :transaction
|
||||
# end
|
||||
config.before(:each, type: :feature) do
|
||||
# :rack_test driver's Rack app under test shares database connection
|
||||
# with the specs, so continue to use transaction strategy for speed.
|
||||
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
|
||||
|
||||
# config.before(:each, js: true) do
|
||||
# DatabaseCleaner.strategy = :truncation
|
||||
# end
|
||||
unless driver_shares_db_connection_with_specs
|
||||
# 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.before(:each) do
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
|
||||
# config.after do
|
||||
# DatabaseCleaner.clean
|
||||
# end
|
||||
config.append_after(:each) do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user