diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 15:07:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 15:07:33 +0300 |
commit | 6b75320f525f841454f1ab162d141d3610f2e77b (patch) | |
tree | 4971c27759e4fbc18b85e71800c3b9c12346317e /spec/lib/gitlab/gpg/commit_spec.rb | |
parent | 4226aca420920c1844e8eade4798a2dff188a6fc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/gpg/commit_spec.rb')
-rw-r--r-- | spec/lib/gitlab/gpg/commit_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb index fa47cfd519b..8401b683fd5 100644 --- a/spec/lib/gitlab/gpg/commit_spec.rb +++ b/spec/lib/gitlab/gpg/commit_spec.rb @@ -370,5 +370,33 @@ describe Gitlab::Gpg::Commit do it_behaves_like 'returns the cached signature on second call' end + + context 'multiple commits with signatures' do + let(:first_signature) { create(:gpg_signature) } + + let(:gpg_key) { create(:gpg_key, key: GpgHelpers::User2.public_key) } + let(:second_signature) { create(:gpg_signature, gpg_key: gpg_key) } + + let!(:first_commit) { create(:commit, project: project, sha: first_signature.commit_sha) } + let!(:second_commit) { create(:commit, project: project, sha: second_signature.commit_sha) } + + let(:commits) do + [first_commit, second_commit].map do |commit| + gpg_commit = described_class.new(commit) + + allow(gpg_commit).to receive(:has_signature?).and_return(true) + + gpg_commit + end + end + + it 'does an aggregated sql request instead of 2 separate ones' do + recorder = ActiveRecord::QueryRecorder.new do + commits.each(&:signature) + end + + expect(recorder.count).to eq(1) + end + end end end |