diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-27 13:59:06 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-28 10:52:13 +0200 |
commit | 20bada3382c21e50c496bf4d6bd4be3a4621b20d (patch) | |
tree | d58a968dd004b7294c573036aac03a03d9de2313 /spec/lib | |
parent | 19a4403443ff6217e6a024667f8ef1eea2f38f4a (diff) | |
download | gitlab-ce-20bada3382c21e50c496bf4d6bd4be3a4621b20d.tar.gz |
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')
-rw-r--r-- | spec/lib/banzai/filter/issue_reference_filter_spec.rb | 13 | ||||
-rw-r--r-- | spec/lib/banzai/filter/merge_request_reference_filter_spec.rb | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index 11607d4fb26..f1082495fcc 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -21,6 +21,19 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do 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 it_behaves_like 'a reference containing an element node' 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 } |