From e1f77c1d0366a1a099d35ef9f4a42b06242ccaf1 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Mon, 9 Jul 2018 10:13:22 +0300 Subject: [PATCH] Add database cleaner to tests that cannot run in a transaction --- test/test_helper.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 7069df7ac..2ef18f98f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,6 +13,7 @@ require 'capybara/minitest' require 'webmock/minitest' require 'selenium/webdriver' require 'support/rails5_assetions' # Remove once upgraded to Rails 5 +require 'database_cleaner' Setting.address_processing = false Setting.registry_country_code = 'US' @@ -42,6 +43,8 @@ class ActionDispatch::IntegrationTest end class JavascriptIntegrationTest < ActionDispatch::IntegrationTest + DatabaseCleaner.strategy = :truncation + Capybara.register_driver(:chrome) do |app| options = ::Selenium::WebDriver::Chrome::Options.new @@ -59,9 +62,17 @@ class JavascriptIntegrationTest < ActionDispatch::IntegrationTest end def setup + DatabaseCleaner.start + super Capybara.current_driver = :chrome Capybara.server = :silent_puma end + + def teardown + super + + DatabaseCleaner.clean + end end