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
27326e61
Commit
27326e61
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoint to update project boards
parent
4214d386
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
2 deletions
+75
-2
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+18
-1
config/routes/project.rb
config/routes/project.rb
+1
-1
spec/controllers/projects/boards_controller_spec.rb
spec/controllers/projects/boards_controller_spec.rb
+56
-0
No files found.
app/controllers/projects/boards_controller.rb
View file @
27326e61
...
...
@@ -2,7 +2,7 @@ class Projects::BoardsController < Projects::ApplicationController
include
IssuableCollections
before_action
:authorize_read_board!
,
only:
[
:index
,
:show
]
before_action
:authorize_admin_board!
,
only:
[
:create
]
before_action
:authorize_admin_board!
,
only:
[
:create
,
:update
]
def
index
@boards
=
::
Boards
::
ListService
.
new
(
project
,
current_user
).
execute
...
...
@@ -40,6 +40,23 @@ class Projects::BoardsController < Projects::ApplicationController
end
end
def
update
board
=
project
.
boards
.
find
(
params
[
:id
])
service
=
::
Boards
::
UpdateService
.
new
(
project
,
current_user
,
board_params
)
service
.
execute
(
board
)
respond_to
do
|
format
|
format
.
json
do
if
board
.
valid?
render
json:
serialize_as_json
(
board
)
else
render
json:
board
.
errors
,
status: :unprocessable_entity
end
end
end
end
private
def
authorize_admin_board!
...
...
config/routes/project.rb
View file @
27326e61
...
...
@@ -459,7 +459,7 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only:
end
end
resources
:boards
,
only:
[
:index
,
:show
,
:create
]
do
resources
:boards
,
only:
[
:index
,
:show
,
:create
,
:update
]
do
scope
module: :boards
do
resources
:issues
,
only:
[
:update
]
...
...
spec/controllers/projects/boards_controller_spec.rb
View file @
27326e61
...
...
@@ -181,4 +181,60 @@ describe Projects::BoardsController do
format: :json
end
end
describe
'PATCH update'
do
let
(
:board
)
{
create
(
:board
,
project:
project
,
name:
'Backend'
)
}
context
'with valid params'
do
it
'returns a successful 200 response'
do
update_board
board:
board
,
name:
'Frontend'
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns the updated board'
do
update_board
board:
board
,
name:
'Frontend'
expect
(
response
).
to
match_response_schema
(
'board'
)
end
end
context
'with invalid params'
do
it
'returns an unprocessable entity 422 response'
do
update_board
board:
board
,
name:
nil
expect
(
response
).
to
have_http_status
(
422
)
end
end
context
'with invalid board id'
do
it
'returns a not found 404 response'
do
update_board
board:
999
,
name:
'Frontend'
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'with unauthorized user'
do
before
do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:read_project
,
project
).
and_return
(
true
)
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:admin_board
,
project
).
and_return
(
false
)
end
it
'returns a not found 404 response'
do
update_board
board:
board
,
name:
'Backend'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
).
to
have_http_status
(
404
)
end
end
def
update_board
(
board
:,
name
:)
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
board
.
to_param
,
board:
{
name:
name
},
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