summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-08-02 14:22:18 -0700
committerStan Hu <stanhu@gmail.com>2018-08-02 16:06:17 -0700
commit3fda119ea35a76bc07accfdacee55cb5b6c880cf (patch)
tree0eae820f211f860a223e6a6d4fd9543375f0a8b7 /spec/workers
parent93c7b6c51a49a1939a876f2510a69e59827ac816 (diff)
downloadgitlab-ce-3fda119ea35a76bc07accfdacee55cb5b6c880cf.tar.gz
Make CreateGpgSignatureWorker backwards compatible with original method signature
Older versions of GitPushService push a single commit SHA string to the queue, but Gitaly requires that the parameters sent by CreateGpgSignatureWorker are an array. It's possible to have old workers using this original signature or jobs in the retry queue that would fail if CreateGpgSignatureWorker can't handle the string form.
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/create_gpg_signature_worker_spec.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/workers/create_gpg_signature_worker_spec.rb b/spec/workers/create_gpg_signature_worker_spec.rb
index 502765e9786..f5479e57260 100644
--- a/spec/workers/create_gpg_signature_worker_spec.rb
+++ b/spec/workers/create_gpg_signature_worker_spec.rb
@@ -4,10 +4,9 @@ describe CreateGpgSignatureWorker do
let(:project) { create(:project, :repository) }
let(:commits) { project.repository.commits('HEAD', limit: 3).commits }
let(:commit_shas) { commits.map(&:id) }
+ let(:gpg_commit) { instance_double(Gitlab::Gpg::Commit) }
context 'when GpgKey is found' do
- let(:gpg_commit) { instance_double(Gitlab::Gpg::Commit) }
-
before do
allow(Project).to receive(:find_by).with(id: project.id).and_return(project)
allow(project).to receive(:commits_by).with(oids: commit_shas).and_return(commits)
@@ -36,6 +35,16 @@ describe CreateGpgSignatureWorker do
end
end
+ context 'handles when a string is passed in for the commit SHA' do
+ it 'creates a signature once' do
+ allow(Gitlab::Gpg::Commit).to receive(:new).with(commits.first).and_return(gpg_commit)
+
+ expect(gpg_commit).to receive(:signature).once
+
+ described_class.new.perform(commit_shas.first, project.id)
+ end
+ end
+
context 'when Commit is not found' do
let(:nonexisting_commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a34' }