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

26 lines
609 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-07-07 11:18:12 +05:30
module DbCleaner
2021-10-27 15:23:28 +05:30
def all_connection_classes
::ActiveRecord::Base.connection_handler.connection_pool_names.map(&:constantize)
end
2020-03-13 15:44:24 +05:30
def delete_from_all_tables!(except: [])
except << 'ar_internal_metadata'
2019-09-30 21:07:59 +05:30
DatabaseCleaner.clean_with(:deletion, cache_tables: false, except: except)
end
2019-07-07 11:18:12 +05:30
def deletion_except_tables
2021-11-11 11:23:49 +05:30
['work_item_types']
2014-09-02 18:07:02 +05:30
end
2019-07-07 11:18:12 +05:30
def setup_database_cleaner
2021-10-27 15:23:28 +05:30
all_connection_classes.each do |connection_class|
DatabaseCleaner[:active_record, { connection: connection_class }]
end
2014-09-02 18:07:02 +05:30
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
DbCleaner.prepend_mod_with('DbCleaner')