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
ae70b705
Commit
ae70b705
authored
Feb 10, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Boards::ListService to find a single board
parent
d6ed219c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
app/services/boards/list_service.rb
app/services/boards/list_service.rb
+14
-7
spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
...es/services/boards/boards_list_service_shared_examples.rb
+15
-0
No files found.
app/services/boards/list_service.rb
View file @
ae70b705
...
...
@@ -5,13 +5,7 @@ module Boards
def
execute
(
create_default_board:
true
)
create_board!
if
create_default_board
&&
parent
.
boards
.
empty?
if
parent
.
multiple_issue_boards_available?
boards
else
# When multiple issue boards are not available
# a user is only allowed to view the default shown board
first_board
end
find_boards
end
private
...
...
@@ -27,5 +21,18 @@ module Boards
def
create_board!
Boards
::
CreateService
.
new
(
parent
,
current_user
).
execute
end
def
find_boards
found
=
if
parent
.
multiple_issue_boards_available?
boards
else
# When multiple issue boards are not available
# a user is only allowed to view the default shown board
first_board
end
params
[
:board_id
].
present?
?
[
found
.
find
(
params
[
:board_id
])]
:
found
end
end
end
spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
View file @
ae70b705
...
...
@@ -50,5 +50,20 @@ RSpec.shared_examples 'multiple boards list service' do
it
'returns boards ordered by name'
do
expect
(
service
.
execute
).
to
eq
[
board_a
,
board_B
,
board_c
]
end
context
'when wanting a specific board'
do
it
'returns board specified by id'
do
service
=
described_class
.
new
(
parent
,
double
,
board_id:
board_c
.
id
)
expect
(
service
.
execute
).
to
eq
[
board_c
]
end
it
'raises exception when board is not found'
do
outside_board
=
create
(
:board
,
resource_parent:
create
(
:project
),
name:
'outside board'
)
service
=
described_class
.
new
(
parent
,
double
,
board_id:
outside_board
.
id
)
expect
{
service
.
execute
}.
to
raise_exception
(
ActiveRecord
::
RecordNotFound
)
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