diff options
Diffstat (limited to 'spec/support/migration.rb')
-rw-r--r-- | spec/support/migration.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/support/migration.rb b/spec/support/migration.rb new file mode 100644 index 00000000000..3c359af886d --- /dev/null +++ b/spec/support/migration.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +RSpec.configure do |config| + # The :each scope runs "inside" the example, so this hook ensures the DB is in the + # correct state before any examples' before hooks are called. This prevents a + # problem where `ScheduleIssuesClosedAtTypeChange` (or any migration that depends + # on background migrations being run inline during test setup) can be broken by + # altering Sidekiq behavior in an unrelated spec like so: + # + # around do |example| + # Sidekiq::Testing.fake! do + # example.run + # end + # end + config.before(:context, :migration) do + schema_migrate_down! + end + + # Each example may call `migrate!`, so we must ensure we are migrated down every time + config.before(:each, :migration) do + use_fake_application_settings + + schema_migrate_down! + end + + config.after(:context, :migration) do + schema_migrate_up! + + Gitlab::CurrentSettings.clear_in_memory_application_settings! + end +end |