Search issuables by iids

This commit is contained in:
Riccardo Padovani 2019-06-18 07:45:47 +00:00 committed by Sean McGivern
parent a25c637c1e
commit b33fb07ef9
3 changed files with 22 additions and 0 deletions

View File

@ -104,6 +104,12 @@ module IssuableCollections
# Used by view to highlight active option
@sort = options[:sort]
# When a user looks for an exact iid, we do not filter by search but only by iid
if params[:search] =~ /^#(?<iid>\d+)\z/
options[:iids] = Regexp.last_match[:iid]
params[:search] = nil
end
if @project
options[:project_id] = @project.id
options[:attempt_project_search_optimizations] = true

View File

@ -0,0 +1,5 @@
---
title: "Search issuables by iids"
merge_request: !28302
author: Riccardo Padovani
type: fixed

View File

@ -180,5 +180,16 @@ describe IssuableCollections do
is_expected.not_to include('invalid_param', 'invalid_array')
end
end
context 'search using an issue iid' do
let(:params) { { search: "#5" } }
it 'mutates the search into a filter by iid' do
is_expected.to include({
'iids' => '5',
'search' => nil
})
end
end
end
end