diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-27 14:59:06 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-28 11:52:13 +0300 |
commit | 20bada3382c21e50c496bf4d6bd4be3a4621b20d (patch) | |
tree | d58a968dd004b7294c573036aac03a03d9de2313 /spec/lib/banzai/filter/merge_request_reference_filter_spec.rb | |
parent | 19a4403443ff6217e6a024667f8ef1eea2f38f4a (diff) |
Add N+1 query problem specs for Issue and MergeRequest ReferenceFilter classes
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/lib/banzai/filter/merge_request_reference_filter_spec.rb')
-rw-r--r-- | spec/lib/banzai/filter/merge_request_reference_filter_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index 3d3d36061f4..40232f6e426 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -17,6 +17,19 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do 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 let(:reference) { merge.to_reference } |