Commit 20bada33 authored by Rémy Coutable's avatar Rémy Coutable

Add N+1 query problem specs for Issue and MergeRequest ReferenceFilter classes

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 19a44034
...@@ -21,6 +21,19 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do ...@@ -21,6 +21,19 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do
end end
end end
describe 'performance' do
let(:another_issue) { create(:issue, project: project) }
it 'does not have a N+1 query problem' do
single_reference = "Issue #{issue.to_reference}"
multiple_references = "Issues #{issue.to_reference} and #{another_issue.to_reference}"
control_count = ActiveRecord::QueryRecorder.new { reference_filter(single_reference).to_html }.count
expect { reference_filter(multiple_references).to_html }.not_to exceed_query_limit(control_count)
end
end
context 'internal reference' do context 'internal reference' do
it_behaves_like 'a reference containing an element node' it_behaves_like 'a reference containing an element node'
......
...@@ -17,6 +17,19 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do ...@@ -17,6 +17,19 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do
end end
end end
describe 'performance' do
let(:another_merge) { create(:merge_request, source_project: project, source_branch: 'fix') }
it 'does not have a N+1 query problem' do
single_reference = "Merge request #{merge.to_reference}"
multiple_references = "Merge requests #{merge.to_reference} and #{another_merge.to_reference}"
control_count = ActiveRecord::QueryRecorder.new { reference_filter(single_reference).to_html }.count
expect { reference_filter(multiple_references).to_html }.not_to exceed_query_limit(control_count)
end
end
context 'internal reference' do context 'internal reference' do
let(:reference) { merge.to_reference } let(:reference) { merge.to_reference }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment