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
Tatuya Kamada
gitlab-ce
Commits
61137670
Commit
61137670
authored
Aug 08, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an endpoint to generate the default lists for a board
parent
68cfdba7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
app/controllers/projects/board_lists_controller.rb
app/controllers/projects/board_lists_controller.rb
+10
-0
config/routes.rb
config/routes.rb
+4
-0
spec/controllers/projects/board_lists_controller_spec.rb
spec/controllers/projects/board_lists_controller_spec.rb
+32
-0
No files found.
app/controllers/projects/board_lists_controller.rb
View file @
61137670
...
...
@@ -33,6 +33,16 @@ class Projects::BoardListsController < Projects::ApplicationController
end
end
def
generate
service
=
Boards
::
Lists
::
GenerateService
.
new
(
project
,
current_user
)
if
service
.
execute
render
json:
project
.
board
.
lists
.
label
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:color
]
}
})
else
head
:unprocessable_entity
end
end
private
def
list_params
...
...
config/routes.rb
View file @
61137670
...
...
@@ -860,6 +860,10 @@ Rails.application.routes.draw do
resources
:issues
,
only:
[
:update
],
controller: :board_issues
resources
:lists
,
only:
[
:create
,
:update
,
:destroy
],
controller: :board_lists
do
collection
do
post
:generate
end
resources
:issues
,
only:
[
:index
],
controller: :board_issues
end
end
...
...
spec/controllers/projects/board_lists_controller_spec.rb
View file @
61137670
...
...
@@ -119,4 +119,36 @@ describe Projects::BoardListsController do
format: :json
end
end
describe
'POST #generate'
do
context
'when board lists is empty'
do
it
'returns a successful 200 response'
do
generate_default_board_lists
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns the defaults lists'
do
generate_default_board_lists
expect
(
response
).
to
match_response_schema
(
'list'
,
array:
true
)
end
end
context
'when board lists is not empty'
do
it
'returns a unprocessable entity 422 response'
do
create
(
:list
,
board:
board
)
generate_default_board_lists
expect
(
response
).
to
have_http_status
(
422
)
end
end
def
generate_default_board_lists
post
:generate
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
format: :json
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