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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
996240a4
Commit
996240a4
authored
Apr 27, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issues/MRs filter when ordering by milestone due date
parent
baa9c660
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
4 deletions
+45
-4
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+2
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-1
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+40
-1
No files found.
app/finders/issuable_finder.rb
View file @
996240a4
...
...
@@ -253,9 +253,9 @@ class IssuableFinder
items
=
items
.
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
.
left_joins_milestones
.
where
(
milestones:
{
title:
params
[
:milestone_title
]
})
if
projects
items
=
items
.
where
(
milestones:
{
project_id:
projects
})
...
...
app/models/concerns/issuable.rb
View file @
996240a4
...
...
@@ -35,10 +35,12 @@ module Issuable
scope
:only_opened
,
->
{
with_state
(
:opened
)
}
scope
:only_reopened
,
->
{
with_state
(
:reopened
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:left_joins_milestones
,
->
{
joins
(
"LEFT OUTER JOIN milestones ON
#{
table_name
}
.milestone_id = milestones.id"
)
}
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
: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
})
}
...
...
spec/models/concerns/issuable_spec.rb
View file @
996240a4
require
'spec_helper'
describe
Issue
,
"Issuable"
do
let
(
:issue
)
{
create
(
:issue
)
}
let
!
(
:issue
)
{
create
(
:issue
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
"Associations"
do
...
...
@@ -114,6 +114,45 @@ describe Issue, "Issuable" do
end
end
describe
"#sort"
do
#Correct order is:
#Issues/MRs with milestones ordered by date
#Issues/MRs with milestones without dates
#Issues/MRs without milestones
let
(
:project
)
{
issue
.
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
)
}
context
"milestone due later"
do
subject
{
Issue
.
where
(
project_id:
project
.
id
).
order_milestone_due_desc
}
before
{
@issues
=
subject
}
it
"puts issues with nil values at the end of collection"
do
expect
(
@issues
.
first
).
to
eq
(
issue2
)
expect
(
@issues
.
second
).
to
eq
(
issue1
)
expect
(
@issues
.
third
).
to
eq
(
issue
)
expect
(
@issues
.
fourth
).
to
eq
(
issue3
)
end
end
context
"milestone due soon"
do
subject
{
Issue
.
where
(
project_id:
project
.
id
).
order_milestone_due_asc
}
before
{
@issues
=
subject
}
it
"puts issues with nil values at the end of collection"
do
expect
(
@issues
.
first
).
to
eq
(
issue1
)
expect
(
@issues
.
second
).
to
eq
(
issue2
)
expect
(
@issues
.
third
).
to
eq
(
issue
)
expect
(
@issues
.
fourth
).
to
eq
(
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