extract shared example
This commit is contained in:
parent
64855c8e30
commit
c5e0bd56fb
|
@ -2,6 +2,19 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Gitlab::Gpg::Commit do
|
describe Gitlab::Gpg::Commit do
|
||||||
describe '#signature' do
|
describe '#signature' do
|
||||||
|
shared_examples 'returns the cached signature on second call' do
|
||||||
|
it 'returns the cached signature on second call' do
|
||||||
|
gpg_commit = described_class.new(commit)
|
||||||
|
|
||||||
|
expect(gpg_commit).to receive(:using_keychain).and_call_original
|
||||||
|
gpg_commit.signature
|
||||||
|
|
||||||
|
# consecutive call
|
||||||
|
expect(gpg_commit).not_to receive(:using_keychain).and_call_original
|
||||||
|
gpg_commit.signature
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
let!(:project) { create :project, :repository, path: 'sample-project' }
|
let!(:project) { create :project, :repository, path: 'sample-project' }
|
||||||
let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' }
|
let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' }
|
||||||
|
|
||||||
|
@ -48,16 +61,7 @@ describe Gitlab::Gpg::Commit do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the cached signature on second call' do
|
it_behaves_like 'returns the cached signature on second call'
|
||||||
gpg_commit = described_class.new(commit)
|
|
||||||
|
|
||||||
expect(gpg_commit).to receive(:using_keychain).and_call_original
|
|
||||||
gpg_commit.signature
|
|
||||||
|
|
||||||
# consecutive call
|
|
||||||
expect(gpg_commit).not_to receive(:using_keychain).and_call_original
|
|
||||||
gpg_commit.signature
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user does not match the committer' do
|
context 'user does not match the committer' do
|
||||||
|
@ -92,6 +96,8 @@ describe Gitlab::Gpg::Commit do
|
||||||
verification_status: 'other_user'
|
verification_status: 'other_user'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'returns the cached signature on second call'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -127,6 +133,8 @@ describe Gitlab::Gpg::Commit do
|
||||||
verification_status: 'unverified_key'
|
verification_status: 'unverified_key'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'returns the cached signature on second call'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -157,16 +165,7 @@ describe Gitlab::Gpg::Commit do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the cached signature on second call' do
|
it_behaves_like 'returns the cached signature on second call'
|
||||||
gpg_commit = described_class.new(commit)
|
|
||||||
|
|
||||||
expect(gpg_commit).to receive(:using_keychain).and_call_original
|
|
||||||
gpg_commit.signature
|
|
||||||
|
|
||||||
# consecutive call
|
|
||||||
expect(gpg_commit).not_to receive(:using_keychain).and_call_original
|
|
||||||
gpg_commit.signature
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue