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
Jérome Perrin
gitlab-ce
Commits
dd309469
Commit
dd309469
authored
Mar 09, 2017
by
George Andrinopoulos
Committed by
Rémy Coutable
Mar 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Order milestone issues by position ascending in api
parent
f1e76a6f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
6 deletions
+40
-6
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+2
-0
app/views/shared/milestones/_issuables.html.haml
app/views/shared/milestones/_issuables.html.haml
+1
-1
changelogs/unreleased/28874-fix-milestone-issues-position-order-in-api.yml
...ased/28874-fix-milestone-issues-position-order-in-api.yml
+4
-0
lib/api/milestones.rb
lib/api/milestones.rb
+4
-2
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+29
-3
No files found.
app/models/concerns/issuable.rb
View file @
dd309469
...
...
@@ -63,6 +63,7 @@ module Issuable
scope
:authored
,
->
(
user
)
{
where
(
author_id:
user
)
}
scope
:assigned_to
,
->
(
u
)
{
where
(
assignee_id:
u
.
id
)}
scope
:recent
,
->
{
reorder
(
id: :desc
)
}
scope
:order_position_asc
,
->
{
reorder
(
position: :asc
)
}
scope
:assigned
,
->
{
where
(
"assignee_id IS NOT NULL"
)
}
scope
:unassigned
,
->
{
where
(
"assignee_id IS NULL"
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
...
...
@@ -144,6 +145,7 @@ module Issuable
when
'downvotes_desc'
then
order_downvotes_desc
when
'upvotes_desc'
then
order_upvotes_desc
when
'priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'position_asc'
then
order_position_asc
else
order_by
(
method
)
end
...
...
app/views/shared/milestones/_issuables.html.haml
View file @
dd309469
...
...
@@ -13,6 +13,6 @@
-
class_prefix
=
dom_class
(
issuables
).
pluralize
%ul
{
class:
"well-list #{class_prefix}-sortable-list"
,
id:
"#{class_prefix}-list-#{id}"
,
"data-state"
=>
id
}
=
render
partial:
'shared/milestones/issuable'
,
collection:
issuables
.
sort_by
(
&
:position
)
,
collection:
issuables
.
order_position_asc
,
as: :issuable
,
locals:
{
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
}
changelogs/unreleased/28874-fix-milestone-issues-position-order-in-api.yml
0 → 100644
View file @
dd309469
---
title
:
Order milestone issues by position ascending in api
merge_request
:
9635
author
:
George Andrinopoulos
lib/api/milestones.rb
View file @
dd309469
...
...
@@ -116,7 +116,8 @@ module API
finder_params
=
{
project_id:
user_project
.
id
,
milestone_title:
milestone
.
title
milestone_title:
milestone
.
title
,
sort:
'position_asc'
}
issues
=
IssuesFinder
.
new
(
current_user
,
finder_params
).
execute
...
...
@@ -138,7 +139,8 @@ module API
finder_params
=
{
project_id:
user_project
.
id
,
milestone_id:
milestone
.
id
milestone_id:
milestone
.
id
,
sort:
'position_asc'
}
merge_requests
=
MergeRequestsFinder
.
new
(
current_user
,
finder_params
).
execute
...
...
spec/requests/api/milestones_spec.rb
View file @
dd309469
...
...
@@ -243,8 +243,8 @@ describe API::Milestones, api: true do
describe
'confidential issues'
do
let
(
:public_project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
public_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
public_project
)
}
let
(
:confidential_issue
)
{
create
(
:issue
,
confidential:
true
,
project:
public_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
public_project
,
position:
2
)
}
let
(
:confidential_issue
)
{
create
(
:issue
,
confidential:
true
,
project:
public_project
,
position:
1
)
}
before
do
public_project
.
team
<<
[
user
,
:developer
]
...
...
@@ -283,11 +283,24 @@ describe API::Milestones, api: true do
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}).
to
include
(
issue
.
id
)
end
it
'returns issues ordered by position asc'
do
get
api
(
"/projects/
#{
public_project
.
id
}
/milestones/
#{
milestone
.
id
}
/issues"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
confidential_issue
.
id
)
expect
(
json_response
.
second
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
end
describe
'GET /projects/:id/milestones/:milestone_id/merge_requests'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
position:
2
)
}
let
(
:another_merge_request
)
{
create
(
:merge_request
,
:simple
,
source_project:
project
,
position:
1
)
}
before
do
milestone
.
merge_requests
<<
merge_request
end
...
...
@@ -320,5 +333,18 @@ describe API::Milestones, api: true do
expect
(
response
).
to
have_http_status
(
401
)
end
it
'returns merge_requests ordered by position asc'
do
milestone
.
merge_requests
<<
another_merge_request
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
/merge_requests"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
another_merge_request
.
id
)
expect
(
json_response
.
second
[
'id'
]).
to
eq
(
merge_request
.
id
)
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