2020-02-06 19:09:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::X509::Commit do
|
|
|
|
describe '#signature' do
|
|
|
|
let(:signature) { described_class.new(commit).signature }
|
|
|
|
|
2020-03-24 17:07:54 -04:00
|
|
|
context 'returns the cached signature' do
|
|
|
|
let(:commit_sha) { '189a6c924013fc3fe40d6f1ec1dc20214183bc97' }
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:commit) { create(:commit, project: project, sha: commit_sha) }
|
2020-02-06 19:09:12 -05:00
|
|
|
|
2020-03-24 17:07:54 -04:00
|
|
|
it 'on second call' do
|
|
|
|
allow_any_instance_of(described_class).to receive(:new).and_call_original
|
|
|
|
expect_any_instance_of(described_class).to receive(:create_cached_signature!).and_call_original
|
2020-02-06 19:09:12 -05:00
|
|
|
|
|
|
|
signature
|
|
|
|
|
|
|
|
# consecutive call
|
2020-03-24 17:07:54 -04:00
|
|
|
expect(described_class).not_to receive(:create_cached_signature!).and_call_original
|
2020-02-06 19:09:12 -05:00
|
|
|
signature
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'unsigned commit' do
|
2020-03-24 17:07:54 -04:00
|
|
|
let!(:project) { create :project, :repository, path: X509Helpers::User1.path }
|
|
|
|
let!(:commit_sha) { X509Helpers::User1.commit }
|
2020-02-06 19:09:12 -05:00
|
|
|
let!(:commit) { create :commit, project: project, sha: commit_sha }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
2020-03-24 17:07:54 -04:00
|
|
|
expect(signature).to be_nil
|
2020-03-10 02:08:07 -04:00
|
|
|
end
|
|
|
|
end
|
2020-02-06 19:09:12 -05:00
|
|
|
end
|
|
|
|
end
|