Class: TestData::TruncatesTestData

Inherits:
Object
  • Object
show all
Defined in:
lib/test_data/truncates_test_data.rb

Instance Method Summary collapse

Constructor Details

#initializeTruncatesTestData

Returns a new instance of TruncatesTestData.



3
4
5
6
# File 'lib/test_data/truncates_test_data.rb', line 3

def initialize
  @config = TestData.config
  @statistics = TestData.statistics
end

Instance Method Details

#callObject



8
9
10
11
12
13
# File 'lib/test_data/truncates_test_data.rb', line 8

def call
  connection.disable_referential_integrity do
    connection.execute("TRUNCATE TABLE #{tables_to_truncate.map { |t| connection.quote_table_name(t) }.join(", ")} #{"CASCADE" unless @config.truncate_these_test_data_tables.present?}")
  end
  @statistics.count_truncate!
end