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
29e34c33
Commit
29e34c33
authored
Mar 07, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve order by priority on issues board
parent
8f667511
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
1 deletion
+49
-1
app/models/issue.rb
app/models/issue.rb
+7
-0
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+1
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+15
-0
spec/services/boards/issues/list_service_spec.rb
spec/services/boards/issues/list_service_spec.rb
+26
-0
No files found.
app/models/issue.rb
View file @
29e34c33
...
...
@@ -96,6 +96,13 @@ class Issue < ActiveRecord::Base
end
end
def
self
.
order_by_position_and_priority
order_labels_priority
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'relative_position'
,
'ASC'
),
Gitlab
::
Database
.
nulls_last_order
(
'highest_priority'
,
'ASC'
),
"id DESC"
)
end
# `from` argument can be a Namespace or Project.
def
to_reference
(
from
=
nil
,
full:
false
)
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
iid
}
"
...
...
app/services/boards/issues/list_service.rb
View file @
29e34c33
...
...
@@ -5,7 +5,7 @@ module Boards
issues
=
IssuesFinder
.
new
(
current_user
,
filter_params
).
execute
issues
=
without_board_labels
(
issues
)
unless
movable_list?
issues
=
with_list_label
(
issues
)
if
movable_list?
issues
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'relative_position'
,
'ASC'
))
issues
.
order_by_position_and_priority
end
private
...
...
spec/models/issue_spec.rb
View file @
29e34c33
...
...
@@ -22,6 +22,21 @@ describe Issue, models: true do
it
{
is_expected
.
to
have_db_index
(
:deleted_at
)
}
end
describe
'#order_by_position_and_priority'
do
let
(
:project
)
{
create
:empty_project
}
let
(
:p1
)
{
create
(
:label
,
title:
'P1'
,
project:
project
,
priority:
1
)
}
let
(
:p2
)
{
create
(
:label
,
title:
'P2'
,
project:
project
,
priority:
2
)
}
let!
(
:issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p1
])
}
let!
(
:issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
])
}
let!
(
:issue3
)
{
create
(
:issue
,
project:
project
,
relative_position:
100
)
}
let!
(
:issue4
)
{
create
(
:issue
,
project:
project
,
relative_position:
200
)
}
it
'returns ordered list'
do
expect
(
project
.
issues
.
order_by_position_and_priority
).
to
match
[
issue3
,
issue4
,
issue1
,
issue2
]
end
end
describe
'#to_reference'
do
let
(
:namespace
)
{
build
(
:namespace
,
path:
'sample-namespace'
)
}
let
(
:project
)
{
build
(
:empty_project
,
name:
'sample-project'
,
namespace:
namespace
)
}
...
...
spec/services/boards/issues/list_service_spec.rb
View file @
29e34c33
...
...
@@ -43,6 +43,32 @@ describe Boards::Issues::ListService, services: true do
described_class
.
new
(
project
,
user
,
params
).
execute
end
context
'issues are ordered by priority'
do
it
'returns opened issues when list_id is missing'
do
params
=
{
board_id:
board
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
opened_issue2
,
reopened_issue1
,
opened_issue1
]
end
it
'returns closed issues when listing issues from Done'
do
params
=
{
board_id:
board
.
id
,
id:
done
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
closed_issue4
,
closed_issue2
,
closed_issue3
,
closed_issue1
]
end
it
'returns opened issues that have label list applied when listing issues from a label list'
do
params
=
{
board_id:
board
.
id
,
id:
list1
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
list1_issue3
,
list1_issue1
,
list1_issue2
]
end
end
context
'with list that does not belong to the board'
do
it
'raises an error'
do
list
=
create
(
:list
)
...
...
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