diff options
author | Stan Hu <stanhu@gmail.com> | 2018-02-19 11:21:47 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-02-19 11:22:13 +0300 |
commit | fdad576838c16d0ae7d181e85a5889d8ae4e5014 (patch) | |
tree | f6ac7d69a2cb59b6e72edae99839977ff52d18b7 /spec | |
parent | 557db7e635c70bf68a15f7029014301013b30070 (diff) |
Fix Error 500 when viewing a commit with a GPG signature in Geo
Closes gitlab-org/gitlab-ee#4825
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/gpg/commit_spec.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb index e3bf2801406..67c62458f0f 100644 --- a/spec/lib/gitlab/gpg/commit_spec.rb +++ b/spec/lib/gitlab/gpg/commit_spec.rb @@ -49,7 +49,9 @@ describe Gitlab::Gpg::Commit do end 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, project: project, gpg_key: gpg_key, @@ -58,9 +60,31 @@ describe Gitlab::Gpg::Commit do gpg_key_user_email: GpgHelpers::User1.emails.first, verification_status: 'verified' ) + expect(signature.persisted?).to be_truthy end 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 context 'commit signed with a subkey' do |