blob: 155dc3c17d9752c06e51b21480309d7d31329e63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# frozen_string_literal: true
module DbCleaner
def all_connection_classes
::ActiveRecord::Base.connection_handler.connection_pool_names.map(&:constantize)
end
def delete_from_all_tables!(except: [])
except << 'ar_internal_metadata'
DatabaseCleaner.clean_with(:deletion, cache_tables: false, except: except)
end
def deletion_except_tables
[]
end
def setup_database_cleaner
all_connection_classes.each do |connection_class|
DatabaseCleaner[:active_record, { connection: connection_class }]
end
end
end
DbCleaner.prepend_mod_with('DbCleaner')
|