Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b1ea0b3c
Commit
b1ea0b3c
authored
Aug 13, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow filtering by issues with no assigned milestone
Closes #1222
parent
28d90385
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
2 deletions
+44
-2
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+5
-1
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+6
-0
app/views/issues/index.html.haml
app/views/issues/index.html.haml
+1
-1
spec/requests/issues_spec.rb
spec/requests/issues_spec.rb
+32
-0
No files found.
app/controllers/issues_controller.rb
View file @
b1ea0b3c
...
@@ -145,9 +145,13 @@ class IssuesController < ApplicationController
...
@@ -145,9 +145,13 @@ class IssuesController < ApplicationController
end
end
@issues
=
@issues
.
where
(
assignee_id:
params
[
:assignee_id
])
if
params
[
:assignee_id
].
present?
@issues
=
@issues
.
where
(
assignee_id:
params
[
:assignee_id
])
if
params
[
:assignee_id
].
present?
@issues
=
@issues
.
where
(
milestone_id:
params
[
:milestone_id
])
if
params
[
:milestone_id
].
present?
@issues
=
@issues
.
tagged_with
(
params
[
:label_name
])
if
params
[
:label_name
].
present?
@issues
=
@issues
.
tagged_with
(
params
[
:label_name
])
if
params
[
:label_name
].
present?
@issues
=
@issues
.
includes
(
:author
,
:project
).
order
(
"updated_at"
)
@issues
=
@issues
.
includes
(
:author
,
:project
).
order
(
"updated_at"
)
# Filter by specific milestone_id (or lack thereof)?
if
params
[
:milestone_id
].
present?
@issues
=
@issues
.
where
(
milestone_id:
(
params
[
:milestone_id
]
==
'0'
?
nil
:
params
[
:milestone_id
]))
end
@issues
@issues
end
end
...
...
app/helpers/issues_helper.rb
View file @
b1ea0b3c
...
@@ -36,4 +36,10 @@ module IssuesHelper
...
@@ -36,4 +36,10 @@ module IssuesHelper
def
issue_tags
def
issue_tags
@project
.
issues
.
tag_counts_on
(
:labels
).
map
(
&
:name
)
@project
.
issues
.
tag_counts_on
(
:labels
).
map
(
&
:name
)
end
end
# Returns a fake Milestone-like object that can be used in a
# <tt>select_tag</tt> to allow filtering by issues with no assigned milestone
def
unassigned_milestone
OpenStruct
.
new
(
id:
0
,
title:
'Unspecified'
)
end
end
end
app/views/issues/index.html.haml
View file @
b1ea0b3c
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
=
form_tag
project_issues_path
(
@project
),
method: :get
,
class: :right
do
=
form_tag
project_issues_path
(
@project
),
method: :get
,
class: :right
do
=
select_tag
(
:label_name
,
options_for_select
(
issue_tags
,
params
[
:label_name
]),
prompt:
"Labels"
)
=
select_tag
(
:label_name
,
options_for_select
(
issue_tags
,
params
[
:label_name
]),
prompt:
"Labels"
)
=
select_tag
(
:assignee_id
,
options_from_collection_for_select
(
@project
.
users
.
all
,
"id"
,
"name"
,
params
[
:assignee_id
]),
prompt:
"Assignee"
)
=
select_tag
(
:assignee_id
,
options_from_collection_for_select
(
@project
.
users
.
all
,
"id"
,
"name"
,
params
[
:assignee_id
]),
prompt:
"Assignee"
)
=
select_tag
(
:milestone_id
,
options_from_collection_for_select
(
@project
.
milestones
.
order
(
"id desc"
).
all
,
"id"
,
"title"
,
params
[
:milestone_id
]),
prompt:
"Milestone"
)
=
select_tag
(
:milestone_id
,
options_from_collection_for_select
(
[
unassigned_milestone
]
+
@project
.
milestones
.
order
(
"id desc"
).
all
,
"id"
,
"title"
,
params
[
:milestone_id
]),
prompt:
"Milestone"
)
=
hidden_field_tag
:f
,
params
[
:f
]
=
hidden_field_tag
:f
,
params
[
:f
]
.clearfix
.clearfix
...
...
spec/requests/issues_spec.rb
View file @
b1ea0b3c
...
@@ -89,4 +89,36 @@ describe "Issues" do
...
@@ -89,4 +89,36 @@ describe "Issues" do
page
.
should
have_content
'gitlab'
page
.
should
have_content
'gitlab'
end
end
end
end
describe
"Filter issue"
do
before
do
[
'foobar'
,
'barbaz'
,
'gitlab'
].
each
do
|
title
|
@issue
=
Factory
:issue
,
author:
@user
,
assignee:
@user
,
project:
project
,
title:
title
end
@issue
=
Issue
.
first
@issue
.
milestone
=
Factory
(
:milestone
,
project:
project
)
@issue
.
save
end
it
"should allow filtering by issues with no specified milestone"
do
visit
project_issues_path
(
project
,
milestone_id:
'0'
)
page
.
should_not
have_content
'foobar'
page
.
should
have_content
'barbaz'
page
.
should
have_content
'gitlab'
end
it
"should allow filtering by a specified milestone"
do
visit
project_issues_path
(
project
,
milestone_id:
@issue
.
milestone
.
id
)
page
.
should
have_content
'foobar'
page
.
should_not
have_content
'barbaz'
page
.
should_not
have_content
'gitlab'
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment