summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/search_results_spec.rb
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2017-12-15 11:21:12 +0100
committerJan Provaznik <jprovaznik@gitlab.com>2017-12-21 15:43:14 +0100
commitd2f1d585e10e3e728f968ceae6b275e4d9bc59f4 (patch)
tree018fb67888198edd68145f1065826b21940c5136 /spec/lib/gitlab/search_results_spec.rb
parent889c7081f1c8bea2cd2cf7d50854babd7df92f72 (diff)
downloadgitlab-ce-d2f1d585e10e3e728f968ceae6b275e4d9bc59f4.tar.gz
Skip projects filter on merge requests searchjprovazn-search
When searching for merge requests, an additional subquery is added which by default filters only merge requests which belong to source or target project user has permission for. This filter is not needed because more restrictive filter which checks if user has permission for target project is used in the query. So unless a custom projects filter is used by user, it's possible to skip the default projects filter and speed up the final query. Related to #40540
Diffstat (limited to 'spec/lib/gitlab/search_results_spec.rb')
-rw-r--r--spec/lib/gitlab/search_results_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb
index e44a7c23452..a958baab44f 100644
--- a/spec/lib/gitlab/search_results_spec.rb
+++ b/spec/lib/gitlab/search_results_spec.rb
@@ -51,6 +51,17 @@ describe Gitlab::SearchResults do
expect(results.objects('merge_requests')).to include merge_request_2
end
+
+ it 'includes project filter by default' do
+ expect(results).to receive(:project_ids_relation).and_call_original
+ results.objects('merge_requests')
+ end
+
+ it 'it skips project filter if default is used' do
+ allow(results).to receive(:default_project_filter).and_return(true)
+ expect(results).not_to receive(:project_ids_relation)
+ results.objects('merge_requests')
+ end
end
it 'does not list issues on private projects' do