Commit 8b9f9dbb authored by Nick Thomas's avatar Nick Thomas

Make the mergeability check worker idempotent

parent 5c3ddecc
...@@ -1143,7 +1143,7 @@ ...@@ -1143,7 +1143,7 @@
:urgency: :low :urgency: :low
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 1 :weight: 1
:idempotent: :idempotent: true
- :name: migrate_external_diffs - :name: migrate_external_diffs
:feature_category: :source_code_management :feature_category: :source_code_management
:has_external_dependencies: :has_external_dependencies:
......
# frozen_string_literal: true # frozen_string_literal: true
class MergeRequestMergeabilityCheckWorker # rubocop:disable Scalability/IdempotentWorker class MergeRequestMergeabilityCheckWorker
include ApplicationWorker include ApplicationWorker
feature_category :source_code_management feature_category :source_code_management
idempotent!
def perform(merge_request_id) def perform(merge_request_id)
merge_request = MergeRequest.find_by_id(merge_request_id) merge_request = MergeRequest.find_by_id(merge_request_id)
......
...@@ -25,5 +25,16 @@ describe MergeRequestMergeabilityCheckWorker do ...@@ -25,5 +25,16 @@ describe MergeRequestMergeabilityCheckWorker do
subject.perform(merge_request.id) subject.perform(merge_request.id)
end end
end end
it_behaves_like 'an idempotent worker' do
let(:merge_request) { create(:merge_request) }
let(:job_args) { [merge_request.id] }
it 'is mergeable' do
subject
expect(merge_request).to be_mergeable
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment