debian-mirror-gitlab/spec/support/database_cleaner.rb

26 lines
666 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
require_relative 'db_cleaner'
RSpec.configure do |config|
include DbCleaner
2021-10-27 15:23:28 +05:30
# 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-07-07 11:18:12 +05:30
config.before(:suite) do
setup_database_cleaner
2021-10-27 15:23:28 +05:30
DatabaseCleaner.clean_with(:deletion)
2019-07-07 11:18:12 +05:30
end
2019-09-30 21:07:59 +05:30
config.around(:each, :delete) do |example|
self.class.use_transactional_tests = false
2019-07-07 11:18:12 +05:30
2019-09-30 21:07:59 +05:30
example.run
2019-07-07 11:18:12 +05:30
2019-09-30 21:07:59 +05:30
delete_from_all_tables!(except: deletion_except_tables)
2021-10-27 15:23:28 +05:30
self.class.use_transactional_tests = true
2019-07-07 11:18:12 +05:30
end
end