summaryrefslogtreecommitdiff
path: root/spec/support/db_cleaner.rb
blob: ff913ebf22b1b259670b3d14fe8bf844afff0355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module DbCleaner
  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
    DatabaseCleaner[:active_record, { connection: ActiveRecord::Base }]
  end
end

DbCleaner.prepend_mod_with('DbCleaner')