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
ed9943d0
Commit
ed9943d0
authored
Aug 01, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoint to allow users to create a new board list
parent
e1998844
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
1 deletion
+71
-1
app/controllers/projects/board_lists_controller.rb
app/controllers/projects/board_lists_controller.rb
+19
-0
config/routes.rb
config/routes.rb
+3
-1
spec/controllers/projects/board_lists_controller_spec.rb
spec/controllers/projects/board_lists_controller_spec.rb
+49
-0
No files found.
app/controllers/projects/board_lists_controller.rb
0 → 100644
View file @
ed9943d0
class
Projects::BoardListsController
<
Projects
::
ApplicationController
def
create
list
=
Boards
::
Lists
::
CreateService
.
new
(
project
,
list_params
).
execute
respond_to
do
|
format
|
if
list
.
valid?
format
.
json
{
render
json:
list
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:color
]
}
})
}
else
format
.
json
{
render
json:
list
.
errors
,
status: :unprocessable_entity
}
end
end
end
private
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
end
end
config/routes.rb
View file @
ed9943d0
...
...
@@ -856,7 +856,9 @@ Rails.application.routes.draw do
end
end
resource
:board
,
only:
[
:show
]
resource
:board
,
only:
[
:show
]
do
resources
:lists
,
only:
[
:create
],
controller: :board_lists
end
resources
:todos
,
only:
[
:create
]
...
...
spec/controllers/projects/board_lists_controller_spec.rb
0 → 100644
View file @
ed9943d0
require
'spec_helper'
describe
Projects
::
BoardListsController
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user
,
:master
]
sign_in
(
user
)
end
describe
'POST #create'
do
context
'with valid params'
do
let
(
:label
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
it
'returns a successful 200 response'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
label
.
id
},
format: :json
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns the created list'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
label
.
id
},
format: :json
expect
(
response
).
to
match_response_schema
(
'list'
)
end
end
context
'with invalid params'
do
it
'returns an error'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
nil
},
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
parsed_response
[
'label'
]).
to
contain_exactly
"can't be blank"
expect
(
response
).
to
have_http_status
(
422
)
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