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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
5fb1de34
Commit
5fb1de34
authored
May 25, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_15221_2'
parents
318b2245
dac9b421
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
7 deletions
+40
-7
CHANGELOG
CHANGELOG
+1
-0
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+3
-3
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+7
-4
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+29
-0
No files found.
CHANGELOG
View file @
5fb1de34
...
...
@@ -4,6 +4,7 @@ v 8.9.0 (unreleased)
- Redesign navigation for project pages
- Use gitlab-shell v3.0.0
- Changed the Slack build message to use the singular duration if necessary (Aran Koning)
- Fix issues filter when ordering by milestone
v 8.8.2 (unreleased)
- Fix Error 500 when accessing application settings due to nil disabled OAuth sign-in sources
...
...
app/finders/issuable_finder.rb
View file @
5fb1de34
...
...
@@ -250,12 +250,12 @@ class IssuableFinder
def
by_milestone
(
items
)
if
milestones?
if
filter_by_no_milestone?
items
=
items
.
where
(
milestone_id:
[
-
1
,
nil
])
items
=
items
.
left_joins_milestones
.
where
(
milestone_id:
[
-
1
,
nil
])
elsif
filter_by_upcoming_milestone?
upcoming_ids
=
Milestone
.
upcoming_ids_by_projects
(
projects
)
items
=
items
.
joins
(
:milestone
)
.
where
(
milestone_id:
upcoming_ids
)
items
=
items
.
left_joins_milestones
.
where
(
milestone_id:
upcoming_ids
)
else
items
=
items
.
joins
(
:milestone
).
where
(
milestones:
{
title:
params
[
:milestone_title
]
}
)
items
=
items
.
with_milestone
(
params
[
:milestone_title
]
)
if
projects
items
=
items
.
where
(
milestones:
{
project_id:
projects
})
...
...
app/models/concerns/issuable.rb
View file @
5fb1de34
...
...
@@ -31,18 +31,21 @@ module Issuable
scope
:unassigned
,
->
{
where
(
"assignee_id IS NULL"
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_milestones
,
->
(
ids
)
{
where
(
milestone_id:
ids
)
}
scope
:with_milestone
,
->
(
title
)
{
left_joins_milestones
.
where
(
milestones:
{
title:
title
})
}
scope
:opened
,
->
{
with_state
(
:opened
,
:reopened
)
}
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:order_milestone_due_desc
,
->
{
outer_join_milestone
.
reorder
(
'milestones.due_date IS NULL ASC, milestones.due_date DESC, milestones.id DESC'
)
}
scope
:order_milestone_due_asc
,
->
{
outer_join_milestone
.
reorder
(
'milestones.due_date IS NULL ASC, milestones.due_date ASC, milestones.id ASC'
)
}
scope
:without_label
,
->
{
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
name
}
' AND label_links.target_id =
#{
table_name
}
.id"
).
where
(
label_links:
{
id:
nil
})
}
scope
:left_joins_milestones
,
->
{
joins
(
"LEFT OUTER JOIN milestones ON
#{
table_name
}
.milestone_id = milestones.id"
)
}
scope
:order_milestone_due_desc
,
->
{
left_joins_milestones
.
reorder
(
'milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date DESC'
)
}
scope
:order_milestone_due_asc
,
->
{
left_joins_milestones
.
reorder
(
'milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date ASC'
)
}
scope
:without_label
,
->
{
joins
(
"LEFT OUTER JOIN label_links ON label_links.target_type = '
#{
name
}
' AND label_links.target_id =
#{
table_name
}
.id"
).
where
(
label_links:
{
id:
nil
})
}
scope
:join_project
,
->
{
joins
(
:project
)
}
scope
:references_project
,
->
{
references
(
:project
)
}
scope
:non_archived
,
->
{
join_project
.
where
(
projects:
{
archived:
false
})
}
scope
:outer_join_milestone
,
->
{
joins
(
"LEFT OUTER JOIN milestones ON milestones.id =
#{
table_name
}
.milestone_id"
)
}
delegate
:name
,
:email
,
...
...
spec/models/concerns/issuable_spec.rb
View file @
5fb1de34
...
...
@@ -114,6 +114,35 @@ describe Issue, "Issuable" do
end
end
describe
"#sort"
do
let
(
:project
)
{
build_stubbed
(
:empty_project
)
}
context
"by milestone due date"
do
#Correct order is:
#Issues/MRs with milestones ordered by date
#Issues/MRs with milestones without dates
#Issues/MRs without milestones
let!
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:early_milestone
)
{
create
(
:milestone
,
project:
project
,
due_date:
10
.
days
.
from_now
)
}
let!
(
:late_milestone
)
{
create
(
:milestone
,
project:
project
,
due_date:
30
.
days
.
from_now
)
}
let!
(
:issue1
)
{
create
(
:issue
,
project:
project
,
milestone:
early_milestone
)
}
let!
(
:issue2
)
{
create
(
:issue
,
project:
project
,
milestone:
late_milestone
)
}
let!
(
:issue3
)
{
create
(
:issue
,
project:
project
)
}
it
"sorts desc"
do
issues
=
project
.
issues
.
sort
(
'milestone_due_desc'
)
expect
(
issues
).
to
match_array
([
issue2
,
issue1
,
issue
,
issue3
])
end
it
"sorts asc"
do
issues
=
project
.
issues
.
sort
(
'milestone_due_asc'
)
expect
(
issues
).
to
match_array
([
issue1
,
issue2
,
issue
,
issue3
])
end
end
end
describe
'#subscribed?'
do
context
'user is not a participant in the issue'
do
before
{
allow
(
issue
).
to
receive
(
:participants
).
with
(
user
).
and_return
([])
}
...
...
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