Welcome to mirror list, hosted at ThFree Co, Russian Federation.

db_cleaner.rb « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 940ff2751d3ddd820d0f36e19bf7f44da2638fb2 (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
    ['work_item_types']
  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')