diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/lib/banzai/reference_parser/snippet_parser_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
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.rb | 11 |
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 |