summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-01-22 15:22:03 +0000
committerNick Thomas <nick@gitlab.com>2018-01-24 17:25:55 +0000
commitbbe00038da5b10f8c152332da7d72f38b5552262 (patch)
tree6259cd07b60ee611ea501858e6461007212c21bc
parent93ea3234dfaa43204c5f24d4010bbe5070d75c72 (diff)
downloadgitlab-ce-bbe00038da5b10f8c152332da7d72f38b5552262.tar.gz
Work around a bug in DatabaseCleaner when using the deletion strategy on MySQL
-rw-r--r--spec/support/db_cleaner.rb15
1 files changed, 15 insertions, 0 deletions
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