diff options
author | Phil Hughes <me@iamphill.com> | 2018-02-19 15:54:01 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-02-19 15:54:01 +0000 |
commit | 0f5b56f96151b47957e7c497d44f983a23863086 (patch) | |
tree | 4db39f420153447ef7a2554d6fc406ce09aedb17 /spec/lib/gitlab/gpg/commit_spec.rb | |
parent | 704ec01955e98c9098e5e57c2d0cb0c2493af5ad (diff) | |
parent | fb2a76ac484f5bba305abdf7b54a18ee8133f63f (diff) | |
download | gitlab-ce-ph-dispatcher-cleanup.tar.gz |
Merge branch 'master' into ph-dispatcher-cleanupph-dispatcher-cleanup
Diffstat (limited to 'spec/lib/gitlab/gpg/commit_spec.rb')
-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 |