summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-02-16 11:58:59 -0800
committerMichael Kozono <mkozono@gmail.com>2018-02-16 14:40:54 -0800
commit3219afff5741511b5ab544fd141207e13028f93a (patch)
treec87059e0c9e6409f33e3ed34331979c75634caf9 /spec
parent293c51e39900efc8ea2e5ac77af680419f89862d (diff)
downloadgitlab-ce-3219afff5741511b5ab544fd141207e13028f93a.tar.gz
Make :migration specs a little more robust
E.g. https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/52873034
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 85de0a14631..5600c9c6ad5 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -154,6 +154,22 @@ RSpec.configure do |config|
Sidekiq.redis(&:flushall)
end
+ # 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
schema_migrate_down!
end