diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-19 21:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-19 21:09:10 +0300 |
commit | 33795139ea8e72756bee3675b4e16387425e6ab1 (patch) | |
tree | 3ca568fca61482e57810ee30ad5ce4b964a82c4e /spec/support/helpers | |
parent | c7e385e282bcb8505589bce526e692b7bb819ffa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/idempotent_worker_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/support/helpers/idempotent_worker_helper.rb b/spec/support/helpers/idempotent_worker_helper.rb new file mode 100644 index 00000000000..b80758d10bd --- /dev/null +++ b/spec/support/helpers/idempotent_worker_helper.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module IdempotentWorkerHelper + WORKER_EXEC_TIMES = 2 + + def perform_multiple(args = [], worker: described_class.new, exec_times: WORKER_EXEC_TIMES) + Sidekiq::Testing.inline! do + job_args = args.nil? ? [nil] : Array.wrap(args) + + expect(worker).to receive(:perform).exactly(exec_times).and_call_original + + exec_times.times { worker.perform(*job_args) } + end + end +end |