diff options
author | Rémy Coutable <remy@rymai.me> | 2019-02-26 19:55:34 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-03-07 10:13:37 +0300 |
commit | 68b7f99fa4ec7fe8ab0ef08508899ce4dff9ef13 (patch) | |
tree | 8ac3c70ab7dca63927579317243520ae8bd73a52 /spec/support/db_cleaner.rb | |
parent | 12e2c3aa481be41fc08f14d85e49c517e2f3beec (diff) |
Reduce differences in spec/support/db_cleaner.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/support/db_cleaner.rb')
-rw-r--r-- | spec/support/db_cleaner.rb | 50 |
1 files changed, 5 insertions, 45 deletions
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb index 34b9efaaecd..c69fa322073 100644 --- a/spec/support/db_cleaner.rb +++ b/spec/support/db_cleaner.rb @@ -1,49 +1,9 @@ -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 - DatabaseCleaner.clean_with(:truncation) - end - - config.append_after(:context) do - DatabaseCleaner.clean_with(:deletion, cache_tables: false) - end - - config.before do - DatabaseCleaner.strategy = :transaction - end - - config.before(:each, :js) do - DatabaseCleaner.strategy = :deletion, { cache_tables: false } - end - - config.before(:each, :delete) do - DatabaseCleaner.strategy = :deletion, { cache_tables: false } - end - - config.before(:each, :migration) do - DatabaseCleaner.strategy = :deletion, { cache_tables: false } - end - - config.before do - DatabaseCleaner.start +module DbCleaner + def deletion_except_tables + [] end - config.append_after do - DatabaseCleaner.clean + def setup_database_cleaner + DatabaseCleaner[:active_record, { connection: ActiveRecord::Base }] end end |