summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gpg
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 12:07:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 12:07:33 +0000
commit6b75320f525f841454f1ab162d141d3610f2e77b (patch)
tree4971c27759e4fbc18b85e71800c3b9c12346317e /spec/lib/gitlab/gpg
parent4226aca420920c1844e8eade4798a2dff188a6fc (diff)
downloadgitlab-ce-6b75320f525f841454f1ab162d141d3610f2e77b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/gpg')
-rw-r--r--spec/lib/gitlab/gpg/commit_spec.rb28
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