Commit 586816ae authored by Douwe Maan's avatar Douwe Maan

Merge branch 'sh-fix-geo-error-500-gpg-commit' into 'master'

Fix Error 500 when viewing a commit with a GPG signature in Geo

Closes gitlab-ee#4825

See merge request gitlab-org/gitlab-ce!17207
parents 637ab60c fdad5768
---
title: Fix Error 500 when viewing a commit with a GPG signature in Geo
merge_request:
author:
type: fixed
...@@ -60,7 +60,9 @@ module Gitlab ...@@ -60,7 +60,9 @@ module Gitlab
def create_cached_signature! def create_cached_signature!
using_keychain do |gpg_key| using_keychain do |gpg_key|
GpgSignature.create!(attributes(gpg_key)) signature = GpgSignature.new(attributes(gpg_key))
signature.save! unless Gitlab::Database.read_only?
signature
end end
end end
......
...@@ -49,7 +49,9 @@ describe Gitlab::Gpg::Commit do ...@@ -49,7 +49,9 @@ describe Gitlab::Gpg::Commit do
end end
it 'returns a valid signature' do it 'returns a valid signature' do
expect(described_class.new(commit).signature).to have_attributes( signature = described_class.new(commit).signature
expect(signature).to have_attributes(
commit_sha: commit_sha, commit_sha: commit_sha,
project: project, project: project,
gpg_key: gpg_key, gpg_key: gpg_key,
...@@ -58,9 +60,31 @@ describe Gitlab::Gpg::Commit do ...@@ -58,9 +60,31 @@ describe Gitlab::Gpg::Commit do
gpg_key_user_email: GpgHelpers::User1.emails.first, gpg_key_user_email: GpgHelpers::User1.emails.first,
verification_status: 'verified' verification_status: 'verified'
) )
expect(signature.persisted?).to be_truthy
end end
it_behaves_like 'returns the cached signature on second call' it_behaves_like 'returns the cached signature on second call'
context 'read-only mode' do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
it 'does not create a cached signature' do
signature = described_class.new(commit).signature
expect(signature).to have_attributes(
commit_sha: commit_sha,
project: project,
gpg_key: gpg_key,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: GpgHelpers::User1.names.first,
gpg_key_user_email: GpgHelpers::User1.emails.first,
verification_status: 'verified'
)
expect(signature.persisted?).to be_falsey
end
end
end end
context 'commit signed with a subkey' do context 'commit signed with a subkey' do
......
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