Commit 5e310367 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'jprovazn-search-issues' into 'master'

Skip projects filter on issues search

See merge request gitlab-org/gitlab-ce!16117
parents 57906a53 017c1297
---
title: Improve search query for issues.
merge_request:
author:
type: performance
...@@ -82,7 +82,10 @@ module Gitlab ...@@ -82,7 +82,10 @@ module Gitlab
end end
def issues def issues
issues = IssuesFinder.new(current_user).execute.where(project_id: project_ids_relation) issues = IssuesFinder.new(current_user).execute
unless default_project_filter
issues = issues.where(project_id: project_ids_relation)
end
issues = issues =
if query =~ /#(\d+)\z/ if query =~ /#(\d+)\z/
......
...@@ -52,18 +52,39 @@ describe Gitlab::SearchResults do ...@@ -52,18 +52,39 @@ describe Gitlab::SearchResults do
expect(results.objects('merge_requests')).to include merge_request_2 expect(results.objects('merge_requests')).to include merge_request_2
end end
describe '#merge_requests' do
it 'includes project filter by default' do it 'includes project filter by default' do
expect(results).to receive(:project_ids_relation).and_call_original expect(results).to receive(:project_ids_relation).and_call_original
results.objects('merge_requests') results.objects('merge_requests')
end end
it 'it skips project filter if default is used' do it 'it skips project filter if default project context is used' do
allow(results).to receive(:default_project_filter).and_return(true) allow(results).to receive(:default_project_filter).and_return(true)
expect(results).not_to receive(:project_ids_relation) expect(results).not_to receive(:project_ids_relation)
results.objects('merge_requests') results.objects('merge_requests')
end end
end end
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
it 'does not list issues on private projects' do it 'does not list issues on private projects' do
private_project = create(:project, :private) private_project = create(:project, :private)
issue = create(:issue, project: private_project, title: 'foo') issue = create(:issue, project: private_project, title: 'foo')
......
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