diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 18:09:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 18:09:36 +0300 |
commit | 074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (patch) | |
tree | f185c474ddc8624a4793c84b0b1f4cc07349694b /spec/lib/gitlab/sidekiq_middleware | |
parent | 8f9beefac3774b30e911fb00a68f4c7a5244cf27 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/sidekiq_middleware')
-rw-r--r-- | spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/sidekiq_middleware/duplicate_jobs_spec.rb | 31 |
2 files changed, 33 insertions, 1 deletions
diff --git a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb index 058e0737a25..e11613b202d 100644 --- a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job_spec.rb @@ -129,7 +129,8 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gitlab_r before do allow(AuthorizedProjectsWorker).to receive(:idempotent?).and_return(idempotent) allow(duplicate_job).to receive(:duplicate?).and_return(duplicate) - stub_feature_flags(drop_duplicate_sidekiq_jobs: feature_enabled) + allow(Gitlab::SidekiqMiddleware::DuplicateJobs) + .to receive(:drop_duplicates?).with(queue).and_return(feature_enabled) end it 'is droppable when all conditions are met' do diff --git a/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs_spec.rb b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs_spec.rb new file mode 100644 index 00000000000..fa5938f470b --- /dev/null +++ b/spec/lib/gitlab/sidekiq_middleware/duplicate_jobs_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::SidekiqMiddleware::DuplicateJobs do + using RSpec::Parameterized::TableSyntax + + describe '.drop_duplicates?' do + where(:global_feature_enabled, :selected_queue_enabled, :queue, :expected) do + true | true | described_class::DROPPABLE_QUEUES.first | true + true | true | "other_queue" | true + true | false | described_class::DROPPABLE_QUEUES.first | true + true | false | "other_queue" | true + false | true | described_class::DROPPABLE_QUEUES.first | true + false | true | "other_queue" | false + false | false | described_class::DROPPABLE_QUEUES.first | false + false | false | "other_queue" | false + end + + with_them do + before do + stub_feature_flags(drop_duplicate_sidekiq_jobs: global_feature_enabled, + drop_duplicate_sidekiq_jobs_for_queue: selected_queue_enabled) + end + + it "allows dropping jobs when expected" do + expect(described_class.drop_duplicates?(queue)).to be(expected) + end + end + end +end |