Commit 87b8e213 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'osw-mark-create-gpg-worker-as-idempotent' into 'master'

Mark CreateCommitSignatureWorker as idempotent

See merge request gitlab-org/gitlab!31414
parents 7d0757b4 39ef11a6
......@@ -961,7 +961,7 @@
:urgency: :low
:resource_boundary: :unknown
:weight: 2
:idempotent:
:idempotent: true
- :name: create_evidence
:feature_category: :release_evidence
:has_external_dependencies:
......
# frozen_string_literal: true
class CreateCommitSignatureWorker # rubocop:disable Scalability/IdempotentWorker
class CreateCommitSignatureWorker
include ApplicationWorker
feature_category :source_code_management
weight 2
idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(commit_shas, project_id)
# Older versions of Git::BranchPushService may push a single commit ID on
......
......@@ -17,6 +17,25 @@ describe CreateCommitSignatureWorker do
subject { described_class.new.perform(commit_shas, project.id) }
context 'when a signature is found' do
it_behaves_like 'an idempotent worker' do
let(:job_args) { [commit_shas, project.id] }
before do
# Removing the stub which can cause bugs for multiple calls to
# Project#commits_by.
allow(project).to receive(:commits_by).and_call_original
# Making sure it still goes through all the perform execution.
allow_next_instance_of(::Commit) do |commit|
allow(commit).to receive(:signature_type).and_return(:PGP)
end
allow_next_instance_of(::Gitlab::Gpg::Commit) do |gpg|
expect(gpg).to receive(:signature).once.and_call_original
end
end
end
it 'calls Gitlab::Gpg::Commit#signature' do
commits.each do |commit|
allow(commit).to receive(:signature_type).and_return(:PGP)
......
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