summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiccardo Padovani <riccardo@rpadovani.com>2019-06-18 07:45:47 +0000
committerSean McGivern <sean@gitlab.com>2019-06-18 07:45:47 +0000
commitb33fb07ef9d2fdf0ce983ded13f9c36ed02e2fd8 (patch)
tree5d0676ce69d41323197f9dd86e7d58fe52127fad
parenta25c637c1e55b3fb94277ac94c4a1ef592cb825d (diff)
downloadgitlab-ce-b33fb07ef9d2fdf0ce983ded13f9c36ed02e2fd8.tar.gz
Search issuables by iids
-rw-r--r--app/controllers/concerns/issuable_collections.rb6
-rw-r--r--changelogs/unreleased/-30974-issue-search-by-number.yml5
-rw-r--r--spec/controllers/concerns/issuable_collections_spec.rb11
3 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb
index 9cf25915e92..88a0690938a 100644
--- a/app/controllers/concerns/issuable_collections.rb
+++ b/app/controllers/concerns/issuable_collections.rb
@@ -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
diff --git a/changelogs/unreleased/-30974-issue-search-by-number.yml b/changelogs/unreleased/-30974-issue-search-by-number.yml
new file mode 100644
index 00000000000..1e6642ec102
--- /dev/null
+++ b/changelogs/unreleased/-30974-issue-search-by-number.yml
@@ -0,0 +1,5 @@
+---
+title: "Search issuables by iids"
+merge_request: !28302
+author: Riccardo Padovani
+type: fixed
diff --git a/spec/controllers/concerns/issuable_collections_spec.rb b/spec/controllers/concerns/issuable_collections_spec.rb
index fb2cd5ca955..f210537aad5 100644
--- a/spec/controllers/concerns/issuable_collections_spec.rb
+++ b/spec/controllers/concerns/issuable_collections_spec.rb
@@ -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