summaryrefslogtreecommitdiff
path: root/spec/support/matchers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-31 15:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-31 15:08:42 +0000
commitc27acb1d376f7127cd33eadcc8f5683ed55262bc (patch)
tree685c31391dca71a73782b5c8626f4ef5b582dc21 /spec/support/matchers
parent1808454313ed75c92e1384466e8c83bfbc8ae25e (diff)
downloadgitlab-ce-c27acb1d376f7127cd33eadcc8f5683ed55262bc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/matchers')
-rw-r--r--spec/support/matchers/background_migrations_matchers.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/matchers/background_migrations_matchers.rb b/spec/support/matchers/background_migrations_matchers.rb
index c38aa7ad6a6..8735dac8b2a 100644
--- a/spec/support/matchers/background_migrations_matchers.rb
+++ b/spec/support/matchers/background_migrations_matchers.rb
@@ -26,3 +26,26 @@ RSpec::Matchers.define :be_scheduled_migration do |*expected|
"Migration `#{migration}` with args `#{expected.inspect}` not scheduled!"
end
end
+
+RSpec::Matchers.define :be_scheduled_migration_with_multiple_args do |*expected|
+ match do |migration|
+ BackgroundMigrationWorker.jobs.any? do |job|
+ args = job['args'].size == 1 ? [BackgroundMigrationWorker.jobs[0]['args'][0], []] : job['args']
+ args[0] == migration && compare_args(args, expected)
+ end
+ end
+
+ failure_message do |migration|
+ "Migration `#{migration}` with args `#{expected.inspect}` not scheduled!"
+ end
+
+ def compare_args(args, expected)
+ args[1].map.with_index do |arg, i|
+ arg.is_a?(Array) ? same_arrays?(arg, expected[i]) : arg == expected[i]
+ end.all?
+ end
+
+ def same_arrays?(arg, expected)
+ arg.sort == expected.sort
+ end
+end