Commit 5a90d044f7fddf28b4dc3cd541315bce862f2866
1 parent
b1ea0b3c
Exists in
master
and in
4 other branches
Allow filtering by issues with no assigned... assignee
Continues #1222
Showing
4 changed files
with
28 additions
and
2 deletions
Show diff stats
app/controllers/issues_controller.rb
@@ -144,14 +144,19 @@ class IssuesController < ApplicationController | @@ -144,14 +144,19 @@ class IssuesController < ApplicationController | ||
144 | else @project.issues.opened | 144 | else @project.issues.opened |
145 | end | 145 | end |
146 | 146 | ||
147 | - @issues = @issues.where(assignee_id: params[:assignee_id]) if params[:assignee_id].present? | ||
148 | @issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present? | 147 | @issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present? |
149 | @issues = @issues.includes(:author, :project).order("updated_at") | 148 | @issues = @issues.includes(:author, :project).order("updated_at") |
150 | 149 | ||
150 | + # Filter by specific assignee_id (or lack thereof)? | ||
151 | + if params[:assignee_id].present? | ||
152 | + @issues = @issues.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) | ||
153 | + end | ||
154 | + | ||
151 | # Filter by specific milestone_id (or lack thereof)? | 155 | # Filter by specific milestone_id (or lack thereof)? |
152 | if params[:milestone_id].present? | 156 | if params[:milestone_id].present? |
153 | @issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) | 157 | @issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) |
154 | end | 158 | end |
159 | + | ||
155 | @issues | 160 | @issues |
156 | end | 161 | end |
157 | 162 |
app/helpers/issues_helper.rb
@@ -42,4 +42,8 @@ module IssuesHelper | @@ -42,4 +42,8 @@ module IssuesHelper | ||
42 | def unassigned_milestone | 42 | def unassigned_milestone |
43 | OpenStruct.new(id: 0, title: 'Unspecified') | 43 | OpenStruct.new(id: 0, title: 'Unspecified') |
44 | end | 44 | end |
45 | + | ||
46 | + def unassigned_issue | ||
47 | + OpenStruct.new(id: 0, name: 'Unassigned') | ||
48 | + end | ||
45 | end | 49 | end |
app/views/issues/index.html.haml
@@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
49 | .right | 49 | .right |
50 | = form_tag project_issues_path(@project), method: :get, class: :right do | 50 | = form_tag project_issues_path(@project), method: :get, class: :right do |
51 | = select_tag(:label_name, options_for_select(issue_tags, params[:label_name]), prompt: "Labels") | 51 | = select_tag(:label_name, options_for_select(issue_tags, params[:label_name]), prompt: "Labels") |
52 | - = select_tag(:assignee_id, options_from_collection_for_select(@project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee") | 52 | + = select_tag(:assignee_id, options_from_collection_for_select([unassigned_issue] + @project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee") |
53 | = select_tag(:milestone_id, options_from_collection_for_select([unassigned_milestone] + @project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), prompt: "Milestone") | 53 | = select_tag(:milestone_id, options_from_collection_for_select([unassigned_milestone] + @project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), prompt: "Milestone") |
54 | = hidden_field_tag :f, params[:f] | 54 | = hidden_field_tag :f, params[:f] |
55 | .clearfix | 55 | .clearfix |
spec/requests/issues_spec.rb
@@ -102,6 +102,7 @@ describe "Issues" do | @@ -102,6 +102,7 @@ describe "Issues" do | ||
102 | 102 | ||
103 | @issue = Issue.first | 103 | @issue = Issue.first |
104 | @issue.milestone = Factory(:milestone, project: project) | 104 | @issue.milestone = Factory(:milestone, project: project) |
105 | + @issue.assignee = nil | ||
105 | @issue.save | 106 | @issue.save |
106 | end | 107 | end |
107 | 108 | ||
@@ -120,5 +121,21 @@ describe "Issues" do | @@ -120,5 +121,21 @@ describe "Issues" do | ||
120 | page.should_not have_content 'barbaz' | 121 | page.should_not have_content 'barbaz' |
121 | page.should_not have_content 'gitlab' | 122 | page.should_not have_content 'gitlab' |
122 | end | 123 | end |
124 | + | ||
125 | + it "should allow filtering by issues with no specified assignee" do | ||
126 | + visit project_issues_path(project, assignee_id: '0') | ||
127 | + | ||
128 | + page.should have_content 'foobar' | ||
129 | + page.should_not have_content 'barbaz' | ||
130 | + page.should_not have_content 'gitlab' | ||
131 | + end | ||
132 | + | ||
133 | + it "should allow filtering by a specified assignee" do | ||
134 | + visit project_issues_path(project, assignee_id: @user.id) | ||
135 | + | ||
136 | + page.should_not have_content 'foobar' | ||
137 | + page.should have_content 'barbaz' | ||
138 | + page.should have_content 'gitlab' | ||
139 | + end | ||
123 | end | 140 | end |
124 | end | 141 | end |