diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-04-26 18:49:19 +0300 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-07-12 05:39:14 +0300 |
commit | d4a919679a1eb5d3e2aaed4b920e6027d2482971 (patch) | |
tree | cdaaeb66e7de69a71994e08dd65478cab364fa24 /spec/support/database_cleaner.rb | |
parent | ecffca5d92353d55aaf8f984737fa617782310e0 (diff) |
Use transactions in JS feature specs
Uses Rails transactional tests instead of DatabaseCleaner
transaction strategy because that doesn't work with JS tests
Diffstat (limited to 'spec/support/database_cleaner.rb')
-rw-r--r-- | spec/support/database_cleaner.rb | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index edd7de94203..f0dd6c52b74 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -26,31 +26,22 @@ RSpec.configure do |config| end config.append_after(:context) do - DatabaseCleaner.clean_with(:deletion, cache_tables: false) + delete_from_all_tables! end - config.before do - setup_database_cleaner - DatabaseCleaner.strategy = :transaction - end + config.around(:each, :delete) do |example| + self.class.use_transactional_tests = false - config.before(:each, :js) do - DatabaseCleaner.strategy = :deletion, { except: deletion_except_tables, cache_tables: false } - end + example.run - config.before(:each, :delete) do - DatabaseCleaner.strategy = :deletion, { except: deletion_except_tables, cache_tables: false } + delete_from_all_tables!(except: deletion_except_tables) end - config.before(:each, :migration) do - DatabaseCleaner.strategy = :deletion, { cache_tables: false } - end + config.around(:each, :migration) do |example| + self.class.use_transactional_tests = false - config.before do - DatabaseCleaner.start - end + example.run - config.append_after do - DatabaseCleaner.clean + delete_from_all_tables! end end |