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
8be2fedb
Commit
8be2fedb
authored
Aug 26, 2020
by
charlie ablett
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix_all_lists' into 'master'
Fix all_list board param See merge request gitlab-org/gitlab!40006
parents
7a67a29c
7919587e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
110 deletions
+126
-110
ee/app/services/ee/boards/issues/list_service.rb
ee/app/services/ee/boards/issues/list_service.rb
+2
-0
ee/spec/services/ee/boards/issues/list_service_spec.rb
ee/spec/services/ee/boards/issues/list_service_spec.rb
+124
-110
No files found.
ee/app/services/ee/boards/issues/list_service.rb
View file @
8be2fedb
...
...
@@ -8,6 +8,8 @@ module EE
override
:filter
def
filter
(
issues
)
return
issues
if
params
[
:all_lists
]
unless
list
&
.
movable?
||
list
&
.
closed?
issues
=
without_assignees_from_lists
(
issues
)
issues
=
without_milestones_from_lists
(
issues
)
...
...
ee/spec/services/ee/boards/issues/list_service_spec.rb
View file @
8be2fedb
...
...
@@ -4,46 +4,40 @@ require 'spec_helper'
RSpec
.
describe
Boards
::
Issues
::
ListService
,
services:
true
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:empty_repo
,
namespace:
group
)
}
let
(
:project1
)
{
create
(
:project
,
:empty_repo
,
namespace:
group
)
}
let
(
:board
)
{
create
(
:board
,
group:
group
)
}
let
(
:m1
)
{
create
(
:milestone
,
group:
group
)
}
let
(
:m2
)
{
create
(
:milestone
,
group:
group
)
}
let
(
:bug
)
{
create
(
:group_label
,
group:
group
,
name:
'Bug'
)
}
let
(
:development
)
{
create
(
:group_label
,
group:
group
,
name:
'Development'
)
}
let
(
:testing
)
{
create
(
:group_label
,
group:
group
,
name:
'Testing'
)
}
let
(
:p1
)
{
create
(
:group_label
,
title:
'P1'
,
group:
group
)
}
let
(
:p2
)
{
create
(
:group_label
,
title:
'P2'
,
group:
group
)
}
let
(
:p3
)
{
create
(
:group_label
,
title:
'P3'
,
group:
group
)
}
let
(
:user_list
)
{
create
(
:user_list
,
board:
board
,
position:
2
)
}
let
(
:milestone
)
{
create
(
:milestone
,
group:
group
)
}
let
(
:milestone_list
)
{
create
(
:milestone_list
,
board:
board
,
position:
3
,
milestone:
milestone
)
}
let
(
:backlog
)
{
create
(
:backlog_list
,
board:
board
)
}
let
(
:list1
)
{
create
(
:list
,
board:
board
,
label:
development
,
position:
0
)
}
let
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let
(
:closed
)
{
create
(
:closed_list
,
board:
board
)
}
let!
(
:opened_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
weight:
9
,
title:
'Issue 1'
,
labels:
[
bug
])
}
let!
(
:opened_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
weight:
1
,
title:
'Issue 2'
,
labels:
[
p2
])
}
let!
(
:opened_issue3
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
title:
'Assigned Issue'
,
labels:
[
p3
])
}
let!
(
:reopened_issue1
)
{
create
(
:issue
,
state:
'opened'
,
project:
project
,
title:
'Issue 3'
,
closed_at:
Time
.
current
)
}
let
(
:list1_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
labels:
[
p2
,
development
])
}
let
(
:list1_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
labels:
[
development
])
}
let
(
:list1_issue3
)
{
create
(
:labeled_issue
,
project:
project1
,
milestone:
m1
,
labels:
[
development
,
p1
])
}
let
(
:list2_issue1
)
{
create
(
:labeled_issue
,
project:
project1
,
milestone:
m1
,
labels:
[
testing
])
}
let
(
:closed_issue1
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let
(
:closed_issue2
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
p3
])
}
let
(
:closed_issue3
)
{
create
(
:issue
,
:closed
,
project:
project1
)
}
let
(
:closed_issue4
)
{
create
(
:labeled_issue
,
:closed
,
project:
project1
,
labels:
[
p1
])
}
let
(
:closed_issue5
)
{
create
(
:labeled_issue
,
:closed
,
project:
project1
,
labels:
[
development
])
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:empty_repo
,
namespace:
group
)
}
let_it_be
(
:project1
)
{
create
(
:project
,
:empty_repo
,
namespace:
group
)
}
let_it_be
(
:board
,
reload:
true
)
{
create
(
:board
,
group:
group
)
}
let_it_be
(
:m1
)
{
create
(
:milestone
,
group:
group
)
}
let_it_be
(
:m2
)
{
create
(
:milestone
,
group:
group
)
}
let_it_be
(
:bug
)
{
create
(
:group_label
,
group:
group
,
name:
'Bug'
)
}
let_it_be
(
:development
)
{
create
(
:group_label
,
group:
group
,
name:
'Development'
)
}
let_it_be
(
:testing
)
{
create
(
:group_label
,
group:
group
,
name:
'Testing'
)
}
let_it_be
(
:p1
)
{
create
(
:group_label
,
title:
'P1'
,
group:
group
)
}
let_it_be
(
:p2
)
{
create
(
:group_label
,
title:
'P2'
,
group:
group
)
}
let_it_be
(
:p3
)
{
create
(
:group_label
,
title:
'P3'
,
group:
group
)
}
let_it_be
(
:milestone
)
{
create
(
:milestone
,
group:
group
)
}
let_it_be
(
:opened_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
weight:
9
,
title:
'Issue 1'
,
labels:
[
bug
])
}
let_it_be
(
:opened_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
weight:
1
,
title:
'Issue 2'
,
labels:
[
p2
])
}
let_it_be
(
:opened_issue3
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
title:
'Assigned Issue'
,
labels:
[
p3
])
}
let_it_be
(
:reopened_issue1
)
{
create
(
:issue
,
state:
'opened'
,
project:
project
,
title:
'Issue 3'
,
closed_at:
Time
.
current
)
}
let_it_be
(
:list1_issue1
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m1
,
labels:
[
p2
,
development
])
}
let_it_be
(
:list1_issue2
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
m2
,
labels:
[
development
])
}
let_it_be
(
:list1_issue3
)
{
create
(
:labeled_issue
,
project:
project1
,
milestone:
m1
,
labels:
[
development
,
p1
])
}
let_it_be
(
:list2_issue1
)
{
create
(
:labeled_issue
,
project:
project1
,
milestone:
m1
,
labels:
[
testing
])
}
let_it_be
(
:closed_issue1
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
bug
])
}
let_it_be
(
:closed_issue2
)
{
create
(
:labeled_issue
,
:closed
,
project:
project
,
labels:
[
p3
])
}
let_it_be
(
:closed_issue3
)
{
create
(
:issue
,
:closed
,
project:
project1
,
milestone:
m1
)
}
let_it_be
(
:closed_issue4
)
{
create
(
:labeled_issue
,
:closed
,
project:
project1
,
labels:
[
p1
])
}
let_it_be
(
:closed_issue5
)
{
create
(
:labeled_issue
,
:closed
,
project:
project1
,
labels:
[
development
])
}
let
(
:parent
)
{
group
}
...
...
@@ -54,117 +48,137 @@ RSpec.describe Boards::Issues::ListService, services: true do
opened_issue3
.
assignees
.
push
(
user_list
.
user
)
end
context
'milestone lists'
do
let!
(
:milestone_issue
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
milestone_list
.
milestone
,
labels:
[
p3
])
}
context
'with assignee, milestone and label lists present'
do
let!
(
:user_list
)
{
create
(
:user_list
,
board:
board
,
position:
2
)
}
let!
(
:milestone_list
)
{
create
(
:milestone_list
,
board:
board
,
position:
3
,
milestone:
milestone
)
}
let!
(
:backlog
)
{
create
(
:backlog_list
,
board:
board
)
}
let!
(
:list1
)
{
create
(
:list
,
board:
board
,
label:
development
,
position:
0
)
}
let!
(
:list2
)
{
create
(
:list
,
board:
board
,
label:
testing
,
position:
1
)
}
let!
(
:closed
)
{
create
(
:closed_list
,
board:
board
)
}
it
'returns issues from milestone persisted in the list
'
do
params
=
{
board_id:
board
.
id
,
id:
milestone_list
.
id
}
context
'milestone lists
'
do
let!
(
:milestone_issue
)
{
create
(
:labeled_issue
,
project:
project
,
milestone:
milestone_list
.
milestone
,
labels:
[
p3
])
}
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
contain_exactly
(
milestone_issue
)
end
context
'backlog list context'
do
it
'returns issues without milestones and without milestones from other lists'
do
params
=
{
board_id:
board
.
id
,
id:
backlog
.
id
}
it
'returns issues from milestone persisted in the list'
do
params
=
{
board_id:
board
.
id
,
id:
milestone_list
.
id
}
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
contain_exactly
(
opened_issue1
,
# milestone from this issue is not in a list
opened_issue2
,
# milestone from this issue is not in a list
reopened_issue1
)
# has no milestone
expect
(
issues
).
to
contain_exactly
(
milestone_issue
)
end
end
end
describe
'#metadata
'
do
it
'returns issues count and weight for list
'
do
params
=
{
board_id:
board
.
id
,
id:
backlog
.
id
}
context
'backlog list context
'
do
it
'returns issues without milestones and without milestones from other lists
'
do
params
=
{
board_id:
board
.
id
,
id:
backlog
.
id
}
metadata
=
described_class
.
new
(
parent
,
user
,
params
).
metadata
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
metadata
[
:size
]).
to
eq
(
3
)
expect
(
metadata
[
:total_weight
]).
to
eq
(
10
)
expect
(
issues
).
to
contain_exactly
(
opened_issue1
,
# milestone from this issue is not in a list
opened_issue2
,
# milestone from this issue is not in a list
reopened_issue1
)
# has no milestone
end
end
end
# When collection is filtered by labels the ActiveRecord::Relation returns '{}' on #count or #sum
# if no issues are found
it
'returns 0 when filtering by labels and issues are not present'
do
params
=
{
board_id:
board
.
id
,
id:
list1
.
id
,
label_name:
[
bug
.
title
,
p2
.
title
]
}
describe
'#metadata'
do
it
'returns issues count and weight for list'
do
params
=
{
board_id:
board
.
id
,
id:
backlog
.
id
}
metadata
=
described_class
.
new
(
parent
,
user
,
params
).
metadata
metadata
=
described_class
.
new
(
parent
,
user
,
params
).
metadata
expect
(
metadata
[
:size
]).
to
eq
(
0
)
expect
(
metadata
[
:total_weight
]).
to
eq
(
0
)
end
end
expect
(
metadata
[
:size
]).
to
eq
(
3
)
expect
(
metadata
[
:total_weight
]).
to
eq
(
10
)
end
context
'when list_id is missing'
do
context
'when board is not scoped by milestone'
do
it
'returns
opened issues without board labels and assignees applied
'
do
params
=
{
board_id:
board
.
id
}
# When collection is filtered by labels the ActiveRecord::Relation returns '{}' on #count or #sum
# if no issues are found
it
'returns
0 when filtering by labels and issues are not present
'
do
params
=
{
board_id:
board
.
id
,
id:
list1
.
id
,
label_name:
[
bug
.
title
,
p2
.
title
]
}
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
metadata
=
described_class
.
new
(
parent
,
user
,
params
).
metadata
expect
(
issues
).
to
match_array
([
opened_issue2
,
reopened_issue1
,
opened_issue1
])
expect
(
metadata
[
:size
]).
to
eq
(
0
)
expect
(
metadata
[
:total_weight
]).
to
eq
(
0
)
end
end
context
'when
board is scoped by milestone
'
do
it
'returns opened issues without board labels, assignees, or milestone applied
'
do
params
=
{
board_id:
board
.
id
}
board
.
update_attribute
(
:milestone
,
m1
)
context
'when
list_id is missing
'
do
context
'when board is not scoped by milestone
'
do
it
'returns opened issues without board labels and assignees applied'
do
params
=
{
board_id:
board
.
id
}
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
)
.
to
match_array
([
opened_issue2
,
list1_issue2
,
reopened_issue1
,
opened_issue1
])
expect
(
issues
).
to
match_array
([
opened_issue2
,
reopened_issue1
,
opened_issue1
]
)
end
end
context
'when milestone is predefined'
do
let
(
:params
)
{
{
board_id:
board
.
id
,
id:
backlog
.
id
}
}
context
'when board is scoped by milestone'
do
it
'returns opened issues without board labels, assignees, or milestone applied'
do
params
=
{
board_id:
board
.
id
}
board
.
update_attribute
(
:milestone
,
m1
)
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
)
.
to
match_array
([
opened_issue2
,
list1_issue2
,
reopened_issue1
,
opened_issue1
])
end
context
'when milestone is predefined'
do
let
(
:params
)
{
{
board_id:
board
.
id
,
id:
backlog
.
id
}
}
context
'as upcoming'
do
before
do
board
.
update
(
milestone_id:
Milestone
::
Upcoming
.
id
)
end
it
'returns open issue for backlog without board label or assignees'
do
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
context
'as upcoming'
do
before
do
board
.
update
(
milestone_id:
Milestone
::
Upcoming
.
id
)
expect
(
issues
).
to
match_array
([
opened_issue2
,
reopened_issue1
,
opened_issue1
])
end
end
it
'returns open issue for backlog without board label or assignees'
do
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
context
'as started'
do
before
do
board
.
update
(
milestone_id:
Milestone
::
Started
.
id
)
end
it
'returns open issue for backlog without board label or assignees'
do
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
match_array
([
opened_issue2
,
reopened_issue1
,
opened_issue1
])
expect
(
issues
).
to
match_array
([
opened_issue2
,
reopened_issue1
,
opened_issue1
])
end
end
end
context
'as started'
do
before
do
board
.
update
(
milestone_id:
Milestone
::
Started
.
id
)
end
context
'when :all_lists param is set'
do
let
(
:params
)
{
{
board_id:
board
.
id
,
all_lists:
true
,
milestone_title:
m1
.
title
}
}
it
'returns
open issue for backlog without board label or assignee
s'
do
it
'returns
matching issues in all board list
s'
do
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
match_array
([
opened_issue2
,
reopened_issue1
,
opened_issue1
])
expect
(
issues
).
to
match_array
([
opened_issue1
,
list1_issue1
,
list1_issue3
,
list2_issue1
,
closed_issue3
])
end
end
end
end
end
context
'when search param is present'
do
it
'returns correct issues'
do
params
=
{
board_id:
board
.
id
,
search:
'Iss'
}
context
'when search param is present'
do
it
'returns correct issues'
do
params
=
{
board_id:
board
.
id
,
search:
'Iss'
}
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
contain_exactly
(
opened_issue1
,
opened_issue2
,
reopened_issue1
)
end
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
contain_exactly
(
opened_issue1
,
opened_issue2
,
reopened_issue1
)
end
it
'returns correct issues using 2 characters'
do
params
=
{
board_id:
board
.
id
,
search:
'Is'
}
it
'returns correct issues using 2 characters'
do
params
=
{
board_id:
board
.
id
,
search:
'Is'
}
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
contain_exactly
(
opened_issue1
,
opened_issue2
,
reopened_issue1
)
issues
=
described_class
.
new
(
parent
,
user
,
params
).
execute
expect
(
issues
).
to
contain_exactly
(
opened_issue1
,
opened_issue2
,
reopened_issue1
)
end
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