From fd090a2fab64332907953a1525cf5c822d983993 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= <rdavila84@gmail.com>
Date: Sat, 2 Apr 2016 07:36:41 -0500
Subject: [PATCH]   Fix bug related to filtering Issues by Label/Milestone.

  This problem only was affecting the dev env.
---
 app/models/concerns/issuable.rb       |  2 +-
 features/dashboard/dashboard.feature  |  8 ++++++++
 features/steps/dashboard/dashboard.rb | 19 +++++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 47ac22995ab..afa2ca039ae 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -42,7 +42,7 @@ module Issuable
 
     scope :join_project, -> { joins(:project) }
     scope :references_project, -> { references(:project) }
-    scope :non_archived, -> { join_project.merge(Project.non_archived.only(:where)) }
+    scope :non_archived, -> { join_project.where(projects: { archived: false }) }
 
     delegate :name,
              :email,
diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature
index c3b3577c449..db73309804c 100644
--- a/features/dashboard/dashboard.feature
+++ b/features/dashboard/dashboard.feature
@@ -6,6 +6,7 @@ Feature: Dashboard
     And project "Shop" has push event
     And project "Shop" has CI enabled
     And project "Shop" has CI build
+    And project "Shop" has labels: "bug", "feature", "enhancement"
     And I visit dashboard page
 
   Scenario: I should see projects list
@@ -50,6 +51,13 @@ Feature: Dashboard
     And I visit dashboard issues page
     Then The list should be sorted by "Oldest updated"
 
+  @javascript
+  Scenario: Filtering Issues by label
+    Given project "Shop" has issue "Bugfix1" with label "feature"
+    When I visit dashboard issues page
+    And I filter the list by label "feature"
+    Then I should see "Bugfix1" in issues list
+
   @javascript
   Scenario: Visiting Project's issues after sorting
     Given I visit dashboard issues page
diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb
index 5062e348844..b5980b35102 100644
--- a/features/steps/dashboard/dashboard.rb
+++ b/features/steps/dashboard/dashboard.rb
@@ -87,4 +87,23 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
   step 'I should see 1 project at group list' do
     expect(find('span.last_activity/span')).to have_content('1')
   end
+
+  step 'I filter the list by label "feature"' do
+    page.within ".labels-filter" do
+      find('.dropdown').click
+      click_link "feature"
+    end
+  end
+
+  step 'I should see "Bugfix1" in issues list' do
+    page.within "ul.content-list" do
+      expect(page).to have_content "Bugfix1"
+    end
+  end
+
+  step 'project "Shop" has issue "Bugfix1" with label "feature"' do
+    project = Project.find_by(name: "Shop")
+    issue = create(:issue, title: "Bugfix1", project: project, assignee: current_user)
+    issue.labels << project.labels.find_by(title: 'feature')
+  end
 end
-- 
GitLab