From 6b75320f525f841454f1ab162d141d3610f2e77b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 17 Oct 2019 12:07:33 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/lib/gitlab/gpg/commit_spec.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'spec/lib/gitlab/gpg') 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 -- cgit v1.2.3