From 913c2706e4abaa4bd023008a007c9104260d6437 Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Tue, 4 Apr 2023 16:08:58 -0700 Subject: [PATCH] In tests, directly use `connection.truncate_tables` instead of `ActiveRecord::Tasks::DatabaseTasks.truncate_all` --- spec/support/database_cleaner.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index da48e0d41..c6709eb46 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -5,11 +5,16 @@ config.use_transactional_fixtures = false config.before(:suite) do - ActiveRecord::Tasks::DatabaseTasks.truncate_all + ApplicationRecord.connection_pool.with_connection do |connection| + connection.truncate_tables(*connection.tables) + end end config.around do |example| example.run - ActiveRecord::Tasks::DatabaseTasks.truncate_all + + ApplicationRecord.connection_pool.with_connection do |connection| + connection.truncate_tables(*connection.tables) + end end end