From 3f17f29a22356d9305f981ae2eaac6b30bcfb8d0 Mon Sep 17 00:00:00 2001
From: Phil Hughes <me@iamphill.com>
Date: Fri, 20 Jan 2017 09:49:48 +0000
Subject: [PATCH] Added current user filter to assignee dropdown

Adds an option in the assignee filter dropdown that allows the user to
filter issues that are assigned to them

Closes #26882
---
 app/views/shared/issuable/_search_bar.html.haml  |  4 ++++
 .../filtered_search/dropdown_assignee_spec.rb    | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/app/views/shared/issuable/_search_bar.html.haml b/app/views/shared/issuable/_search_bar.html.haml
index 8d7b1d616f4..964ad924014 100644
--- a/app/views/shared/issuable/_search_bar.html.haml
+++ b/app/views/shared/issuable/_search_bar.html.haml
@@ -47,6 +47,10 @@
               %li.filter-dropdown-item{ 'data-value' => 'none' }
                 %button.btn.btn-link
                   No Assignee
+              - if current_user
+                %li.filter-dropdown-item{ 'data-value' => current_user.to_reference }
+                  %button.btn.btn-link
+                    Assigned to me
               %li.divider
             %ul.filter-dropdown{ 'data-dynamic' => true, 'data-dropdown' => true }
               %li.filter-dropdown-item
diff --git a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
index 3ac9b2e0ae0..16dcc487812 100644
--- a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
@@ -43,6 +43,14 @@ describe 'Dropdown assignee', js: true, feature: true do
       expect(page).to have_css(js_dropdown_assignee, visible: true)
     end
 
+    it 'shows assigned to me link' do
+      filtered_search.set('assignee:')
+
+      page.within js_dropdown_assignee do
+        expect(page).to have_content('Assigned to me')
+      end
+    end
+
     it 'closes when the search bar is unfocused' do
       find('body').click()
 
@@ -121,6 +129,14 @@ describe 'Dropdown assignee', js: true, feature: true do
       filtered_search.set('assignee:')
     end
 
+    it 'filters by current user' do
+      page.within js_dropdown_assignee do
+        click_button 'Assigned to me'
+      end
+
+      expect(filtered_search.value).to eq("assignee:#{user.to_reference}")
+    end
+
     it 'fills in the assignee username when the assignee has not been filtered' do
       click_assignee(user_jacob.name)
 
-- 
2.30.9