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
0382584e
Commit
0382584e
authored
Mar 20, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List issues with another milestone that has a matching board list label
parent
90696194
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
25 deletions
+45
-25
app/services/boards/issues/list_service.rb
app/services/boards/issues/list_service.rb
+8
-4
spec/services/boards/issues/list_service_spec.rb
spec/services/boards/issues/list_service_spec.rb
+37
-21
No files found.
app/services/boards/issues/list_service.rb
View file @
0382584e
...
@@ -51,10 +51,14 @@ module Boards
...
@@ -51,10 +51,14 @@ module Boards
def
without_board_labels
(
issues
)
def
without_board_labels
(
issues
)
return
issues
unless
board_label_ids
.
any?
return
issues
unless
board_label_ids
.
any?
issues
.
where
.
not
(
label_links
=
LabelLink
.
where
(
"label_links.target_type = 'Issue' AND label_links.target_id = issues.id"
)
LabelLink
.
where
(
"label_links.target_type = 'Issue' AND label_links.target_id = issues.id"
)
.
where
(
label_id:
board_label_ids
)
.
where
(
label_id:
board_label_ids
).
limit
(
1
).
arel
.
exists
)
if
board
.
milestone
.
present?
label_links
=
label_links
.
where
(
"issues.milestone_id = ?"
,
board
.
milestone_id
)
end
issues
.
where
.
not
(
label_links
.
limit
(
1
).
arel
.
exists
)
end
end
def
with_list_label
(
issues
)
def
with_list_label
(
issues
)
...
...
spec/services/boards/issues/list_service_spec.rb
View file @
0382584e
...
@@ -6,6 +6,9 @@ describe Boards::Issues::ListService, services: true do
...
@@ -6,6 +6,9 @@ describe Boards::Issues::ListService, services: true do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
let
(
:board
)
{
create
(
:board
,
project:
project
)
}
let
(
:m1
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:m2
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
name:
'Bug'
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
name:
'Bug'
)
}
let
(
:development
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
let
(
:development
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
let
(
:testing
)
{
create
(
:label
,
project:
project
,
name:
'Testing'
)
}
let
(
:testing
)
{
create
(
:label
,
project:
project
,
name:
'Testing'
)
}
...
@@ -17,14 +20,14 @@ describe Boards::Issues::ListService, services: true do
...
@@ -17,14 +20,14 @@ describe Boards::Issues::ListService, services: true do
let!
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let!
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let!
(
:done
)
{
board
.
done_list
}
let!
(
:done
)
{
board
.
done_list
}
let!
(
:opened_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
bug
])
}
let!
(
:opened_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
title:
'Issue 1'
,
labels:
[
bug
])
}
let!
(
:opened_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
])
}
let!
(
:opened_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
title:
'Issue 2'
,
labels:
[
p2
])
}
let!
(
:reopened_issue1
)
{
create
(
:issue
,
:reopened
,
project:
project
)
}
let!
(
:reopened_issue1
)
{
create
(
:issue
,
:reopened
,
project:
project
,
title:
'Issue 3'
,
)
}
let!
(
:list1_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
p2
,
development
])
}
let!
(
:list1_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
labels:
[
p2
,
development
])
}
let!
(
:list1_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
])
}
let!
(
:list1_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
labels:
[
development
])
}
let!
(
:list1_issue3
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
development
,
p1
])
}
let!
(
:list1_issue3
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
labels:
[
development
,
p1
])
}
let!
(
:list2_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
testing
])
}
let!
(
:list2_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
labels:
[
testing
])
}
let!
(
:closed_issue1
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let!
(
:closed_issue1
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let!
(
:closed_issue2
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
p3
])
}
let!
(
:closed_issue2
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
p3
])
}
...
@@ -43,14 +46,28 @@ describe Boards::Issues::ListService, services: true do
...
@@ -43,14 +46,28 @@ describe Boards::Issues::ListService, services: true do
described_class
.
new
(
project
,
user
,
params
).
execute
described_class
.
new
(
project
,
user
,
params
).
execute
end
end
context
'issues are ordered by priority'
do
context
'when list_id is missing'
do
it
'returns opened issues when list_id is missing'
do
context
'when board does not have a milestone'
do
it
'returns opened issues without board labels applied'
do
params
=
{
board_id:
board
.
id
}
params
=
{
board_id:
board
.
id
}
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
opened_issue2
,
reopened_issue1
,
opened_issue1
]
expect
(
issues
).
to
eq
[
opened_issue2
,
reopened_issue1
,
opened_issue1
]
end
end
end
context
'when board have a milestone'
do
it
'returns opened issues without board labels and milestone applied'
do
params
=
{
board_id:
board
.
id
}
board
.
update_attribute
(
:milestone
,
m1
)
issues
=
described_class
.
new
(
project
,
user
,
params
).
execute
expect
(
issues
).
to
eq
[
opened_issue2
,
list1_issue2
,
reopened_issue1
,
opened_issue1
]
end
end
end
it
'returns closed issues when listing issues from Done'
do
it
'returns closed issues when listing issues from Done'
do
params
=
{
board_id:
board
.
id
,
id:
done
.
id
}
params
=
{
board_id:
board
.
id
,
id:
done
.
id
}
...
@@ -67,7 +84,6 @@ describe Boards::Issues::ListService, services: true do
...
@@ -67,7 +84,6 @@ describe Boards::Issues::ListService, services: true do
expect
(
issues
).
to
eq
[
list1_issue3
,
list1_issue1
,
list1_issue2
]
expect
(
issues
).
to
eq
[
list1_issue3
,
list1_issue1
,
list1_issue2
]
end
end
end
context
'with list that does not belong to the board'
do
context
'with list that does not belong to the board'
do
it
'raises an error'
do
it
'raises an error'
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