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>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/lib/banzai/reference_parser/snippet_parser_spec.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/lib/banzai/reference_parser/snippet_parser_spec.rb')
-rw-r--r--spec/lib/banzai/reference_parser/snippet_parser_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
index cdc660b4f4a..3459784708f 100644
--- a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
@@ -33,6 +33,17 @@ RSpec.describe Banzai::ReferenceParser::SnippetParser do
project.project_feature.update_attribute(:snippets_access_level, ProjectFeature::ENABLED)
end
+ it 'avoids N+1 cached queries', :use_sql_query_cache do
+ # Run this once to establish a baseline
+ visible_references(:public)
+
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ subject.nodes_visible_to_user(user, [link])
+ end
+
+ expect { subject.nodes_visible_to_user(user, Array.new(10, link)) }.not_to exceed_all_query_limit(control_count.count)
+ end
+
it 'creates a reference for guest for a public snippet' do
expect(visible_references(:public)).to eq([link])
end