2019-02-26 11:55:34 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative 'db_cleaner'
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
include DbCleaner
|
|
|
|
|
2021-07-27 11:09:49 -04:00
|
|
|
# Ensure the database is empty at the start of the suite run with :deletion strategy
|
|
|
|
# neither the sequence is reset nor the tables are vacuum, but this provides
|
|
|
|
# better I/O performance on machines with slower storage
|
2019-02-26 11:55:34 -05:00
|
|
|
config.before(:suite) do
|
|
|
|
setup_database_cleaner
|
2021-07-27 11:09:49 -04:00
|
|
|
DatabaseCleaner.clean_with(:deletion)
|
2019-02-26 11:55:34 -05:00
|
|
|
end
|
|
|
|
|
2019-04-26 11:49:19 -04:00
|
|
|
config.around(:each, :delete) do |example|
|
|
|
|
self.class.use_transactional_tests = false
|
2019-02-26 11:55:34 -05:00
|
|
|
|
2019-04-26 11:49:19 -04:00
|
|
|
example.run
|
2019-02-26 11:55:34 -05:00
|
|
|
|
2019-04-26 11:49:19 -04:00
|
|
|
delete_from_all_tables!(except: deletion_except_tables)
|
2021-08-19 11:10:29 -04:00
|
|
|
|
|
|
|
self.class.use_transactional_tests = true
|
2019-02-26 11:55:34 -05:00
|
|
|
end
|
2022-10-24 11:11:29 -04:00
|
|
|
|
|
|
|
config.around(:each, :migration) do |example|
|
|
|
|
self.class.use_transactional_tests = false
|
|
|
|
|
|
|
|
example.run
|
|
|
|
|
|
|
|
delete_from_all_tables!(except: deletion_except_tables)
|
|
|
|
|
|
|
|
self.class.use_transactional_tests = true
|
|
|
|
end
|
2019-02-26 11:55:34 -05:00
|
|
|
end
|