Commit 2fbb3cbb authored by Brett Walker's avatar Brett Walker

Check for N+1 in ExternalIssueReferenceFilter

parent 6b983bcb
...@@ -256,4 +256,23 @@ RSpec.describe Banzai::Filter::References::ExternalIssueReferenceFilter do ...@@ -256,4 +256,23 @@ RSpec.describe Banzai::Filter::References::ExternalIssueReferenceFilter do
it_behaves_like "external issue tracker" it_behaves_like "external issue tracker"
end end
end end
context 'checking N+1' do
let_it_be(:integration) { create(:redmine_integration, project: project) }
let_it_be(:issue1) { ExternalIssue.new("#123", project) }
let_it_be(:issue2) { ExternalIssue.new("YT-123", project) }
before do
project.update!(issues_enabled: false)
end
it 'does not have N+1 per multiple references per project', :use_sql_query_cache do
single_reference = "External Issue #{issue1.to_reference}"
multiple_references = "External Issues #{issue1.to_reference} and #{issue2.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
end end
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