diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-06 11:17:09 +0300 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 16:43:37 +0300 |
commit | a7d2ebe508b6dde3b3ae37c5a54fc78719b199b3 (patch) | |
tree | 9c2be2776b5346597e026ac749cd7527635ce8dc /spec | |
parent | 4f7ba8f2861b39d3a7697eb99e3fbaaf39f32643 (diff) |
simplify fetching of commit
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/gpg_signature_spec.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb index 8b60b36452b..c16f15bf4bf 100644 --- a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb +++ b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do end before do - allow(Gitlab::Git::Commit).to receive(:find).with(kind_of(Repository), commit_sha).and_return(raw_commit) + allow_any_instance_of(GpgSignature).to receive(:commit).and_return(commit) end context 'gpg signature did not have an associated gpg key' do diff --git a/spec/models/gpg_signature_spec.rb b/spec/models/gpg_signature_spec.rb index b3f84262874..b6f256e61ee 100644 --- a/spec/models/gpg_signature_spec.rb +++ b/spec/models/gpg_signature_spec.rb @@ -12,4 +12,17 @@ RSpec.describe GpgSignature do it { is_expected.to validate_presence_of(:project) } it { is_expected.to validate_presence_of(:gpg_key_primary_keyid) } end + + describe '#commit' do + it 'fetches the commit through the project' do + commit_sha = '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' + project = create :project + commit = create :commit, project: project + gpg_signature = create :gpg_signature, commit_sha: commit_sha + + expect_any_instance_of(Project).to receive(:commit).with(commit_sha).and_return(commit) + + gpg_signature.commit + end + end end |