diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-08-24 15:21:34 +0300 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-09-05 13:18:31 +0300 |
commit | c5e0bd56fbc0f13e107e6553ea817c130d947ab1 (patch) | |
tree | d07be2c8cf085d8f0835ff1d31fd17dbd195f3a9 /spec/lib/gitlab/gpg | |
parent | 64855c8e30c53004b2e2c2a65f131f8ab7efa41c (diff) |
extract shared example
Diffstat (limited to 'spec/lib/gitlab/gpg')
-rw-r--r-- | spec/lib/gitlab/gpg/commit_spec.rb | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb index 30aa91dde03..843418aef6d 100644 --- a/spec/lib/gitlab/gpg/commit_spec.rb +++ b/spec/lib/gitlab/gpg/commit_spec.rb @@ -2,6 +2,19 @@ require 'rails_helper' describe Gitlab::Gpg::Commit 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!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' } @@ -48,16 +61,7 @@ describe Gitlab::Gpg::Commit do ) end - 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 + it_behaves_like 'returns the cached signature on second call' end context 'user does not match the committer' do @@ -92,6 +96,8 @@ describe Gitlab::Gpg::Commit do verification_status: 'other_user' ) end + + it_behaves_like 'returns the cached signature on second call' end end @@ -127,6 +133,8 @@ describe Gitlab::Gpg::Commit do verification_status: 'unverified_key' ) end + + it_behaves_like 'returns the cached signature on second call' end end @@ -157,16 +165,7 @@ describe Gitlab::Gpg::Commit do ) end - 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 + it_behaves_like 'returns the cached signature on second call' end end end |