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
ef66a4a5
Commit
ef66a4a5
authored
Aug 06, 2018
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing and duplicates on project milestone listing page
parent
415b2f94
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
19 deletions
+57
-19
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-1
app/models/concerns/sortable.rb
app/models/concerns/sortable.rb
+1
-0
app/models/milestone.rb
app/models/milestone.rb
+19
-16
changelogs/unreleased/osw-fix-missing-and-duplicated-milestones-on-list.yml
...sed/osw-fix-missing-and-duplicated-milestones-on-list.yml
+5
-0
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+31
-2
No files found.
app/models/concerns/issuable.rb
View file @
ef66a4a5
...
...
@@ -154,7 +154,7 @@ module Issuable
end
# Break ties with the ID column for pagination
sorted
.
order
(
id: :desc
)
sorted
.
with_order_id_desc
end
def
order_due_date_and_labels_priority
(
excluded_labels:
[])
...
...
app/models/concerns/sortable.rb
View file @
ef66a4a5
...
...
@@ -6,6 +6,7 @@ module Sortable
extend
ActiveSupport
::
Concern
included
do
scope
:with_order_id_desc
,
->
{
order
(
id: :desc
)
}
scope
:order_id_desc
,
->
{
reorder
(
id: :desc
)
}
scope
:order_id_asc
,
->
{
reorder
(
id: :asc
)
}
scope
:order_created_desc
,
->
{
reorder
(
created_at: :desc
)
}
...
...
app/models/milestone.rb
View file @
ef66a4a5
...
...
@@ -146,22 +146,25 @@ class Milestone < ActiveRecord::Base
end
def
self
.
sort_by_attribute
(
method
)
case
method
.
to_s
when
'due_date_asc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'due_date'
,
'ASC'
))
when
'due_date_desc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'due_date'
,
'DESC'
))
when
'name_asc'
reorder
(
Arel
::
Nodes
::
Ascending
.
new
(
arel_table
[
:title
].
lower
))
when
'name_desc'
reorder
(
Arel
::
Nodes
::
Descending
.
new
(
arel_table
[
:title
].
lower
))
when
'start_date_asc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'start_date'
,
'ASC'
))
when
'start_date_desc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'start_date'
,
'DESC'
))
else
order_by
(
method
)
end
sorted
=
case
method
.
to_s
when
'due_date_asc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'due_date'
,
'ASC'
))
when
'due_date_desc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'due_date'
,
'DESC'
))
when
'name_asc'
reorder
(
Arel
::
Nodes
::
Ascending
.
new
(
arel_table
[
:title
].
lower
))
when
'name_desc'
reorder
(
Arel
::
Nodes
::
Descending
.
new
(
arel_table
[
:title
].
lower
))
when
'start_date_asc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'start_date'
,
'ASC'
))
when
'start_date_desc'
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'start_date'
,
'DESC'
))
else
order_by
(
method
)
end
sorted
.
with_order_id_desc
end
##
...
...
changelogs/unreleased/osw-fix-missing-and-duplicated-milestones-on-list.yml
0 → 100644
View file @
ef66a4a5
---
title
:
Fix missing and duplicates on project milestone listing page
merge_request
:
21058
author
:
type
:
fixed
spec/controllers/projects/milestones_controller_spec.rb
View file @
ef66a4a5
...
...
@@ -42,16 +42,45 @@ describe Projects::MilestonesController do
describe
"#index"
do
context
"as html"
do
before
do
get
:index
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
def
render_index
(
project
:,
page
:)
get
:index
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
page:
page
end
it
"queries only projects milestones"
do
render_index
project:
project
,
page:
1
milestones
=
assigns
(
:milestones
)
expect
(
milestones
.
count
).
to
eq
(
1
)
expect
(
milestones
.
where
(
project_id:
nil
)).
to
be_empty
end
it
'renders paginated milestones without missing or duplicates'
do
allow
(
Milestone
).
to
receive
(
:default_per_page
).
and_return
(
2
)
create_list
(
:milestone
,
5
,
project:
project
)
render_index
project:
project
,
page:
1
page_1_milestones
=
assigns
(
:milestones
)
expect
(
page_1_milestones
.
size
).
to
eq
(
2
)
render_index
project:
project
,
page:
2
page_2_milestones
=
assigns
(
:milestones
)
expect
(
page_2_milestones
.
size
).
to
eq
(
2
)
render_index
project:
project
,
page:
3
page_3_milestones
=
assigns
(
:milestones
)
expect
(
page_3_milestones
.
size
).
to
eq
(
2
)
rendered_milestone_ids
=
page_1_milestones
.
pluck
(
:id
)
+
page_2_milestones
.
pluck
(
:id
)
+
page_3_milestones
.
pluck
(
:id
)
expect
(
rendered_milestone_ids
)
.
to
match_array
(
project
.
milestones
.
pluck
(
:id
))
end
end
context
"as json"
do
...
...
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