Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/lib/banzai/filter/references/commit_reference_filter_spec.rb
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/lib/banzai/filter/references/commit_reference_filter_spec.rb')
-rw-r--r--spec/lib/banzai/filter/references/commit_reference_filter_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/references/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/references/commit_reference_filter_spec.rb
index bee8e42d12e..6bcea41a603 100644
--- a/spec/lib/banzai/filter/references/commit_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/references/commit_reference_filter_spec.rb
@@ -269,4 +269,34 @@ RSpec.describe Banzai::Filter::References::CommitReferenceFilter do
expect(reference_filter(act, context).css('a').first.text).to eql("#{project.full_path}@#{commit.short_id}")
end
end
+
+ context 'checking N+1' do
+ let(:namespace2) { create(:namespace) }
+ let(:namespace3) { create(:namespace) }
+ let(:project2) { create(:project, :public, :repository, namespace: namespace2) }
+ let(:project3) { create(:project, :public, :repository, namespace: namespace3) }
+ let(:commit2) { project2.commit }
+ let(:commit3) { project3.commit }
+ let(:commit_reference) { commit.to_reference }
+ let(:commit2_reference) { commit2.to_reference(full: true) }
+ let(:commit3_reference) { commit3.to_reference(full: true) }
+
+ it 'does not have N+1 per multiple references per project', :use_sql_query_cache do
+ markdown = "#{commit_reference}"
+ max_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ reference_filter(markdown)
+ end.count
+
+ markdown = "#{commit_reference} 8b95f2f1 8b95f2f2 8b95f2f3 #{commit2_reference} #{commit3_reference}"
+
+ # Commits are not DB entries, they are on the project itself.
+ # So adding commits from two more projects to the markdown should
+ # only increase by 1 query
+ max_count += 1
+
+ expect do
+ reference_filter(markdown)
+ end.not_to exceed_all_query_limit(max_count)
+ end
+ end
end