From bbe00038da5b10f8c152332da7d72f38b5552262 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Mon, 22 Jan 2018 15:22:03 +0000 Subject: Work around a bug in DatabaseCleaner when using the deletion strategy on MySQL --- spec/support/db_cleaner.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb index 7ca88cc61d3..1809ae1d141 100644 --- a/spec/support/db_cleaner.rb +++ b/spec/support/db_cleaner.rb @@ -1,3 +1,18 @@ +require 'database_cleaner/active_record/deletion' + +module FakeInformationSchema + # Work around a bug in DatabaseCleaner when using the deletion strategy: + # https://github.com/DatabaseCleaner/database_cleaner/issues/347 + # + # On MySQL, if the information schema is said to exist, we use an inaccurate + # row count leading to some tables not being cleaned when they should + def information_schema_exists?(_connection) + false + end +end + +DatabaseCleaner::ActiveRecord::Deletion.prepend(FakeInformationSchema) + RSpec.configure do |config| # Ensure all sequences are reset at the start of the suite run config.before(:suite) do -- cgit v1.2.1