diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2017-12-22 18:44:53 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-01-02 14:07:26 +0300 |
commit | 017c1297cdcfbb7431dbbc0445e29d1c95d934c0 (patch) | |
tree | e3cb16e2473cc744fd75907a53c924d23e0a8bca /spec/lib/gitlab/search_results_spec.rb | |
parent | 05292ba958c20ac560cdc43e90d954cb201eaf62 (diff) |
Skip projects filter on issues search
When searching for issues, an additional subquery
is added which filters only issues in a project. If global context is
used (no project is specified) this query filters all projects user has
access to.
In that case we can skip this filter because filtering only projects
user has access to is added anyway.
The filter is used only if a custom project context is specified
Related to #40540
Diffstat (limited to 'spec/lib/gitlab/search_results_spec.rb')
-rw-r--r-- | spec/lib/gitlab/search_results_spec.rb | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb index a958baab44f..edd3d74f344 100644 --- a/spec/lib/gitlab/search_results_spec.rb +++ b/spec/lib/gitlab/search_results_spec.rb @@ -52,15 +52,36 @@ 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') + describe '#merge_requests' do + 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 project context 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 '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') + describe '#issues' do + it 'includes project filter by default' do + expect(results).to receive(:project_ids_relation).and_call_original + + results.objects('issues') + end + + it 'it skips project filter if default project context is used' do + allow(results).to receive(:default_project_filter).and_return(true) + + expect(results).not_to receive(:project_ids_relation) + + results.objects('issues') + end end end |