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
723ed9cc
Commit
723ed9cc
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Projects::BoardsController#show to look up for a specific board
parent
ecf4c10e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
11 deletions
+41
-11
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+13
-2
spec/controllers/projects/boards_controller_spec.rb
spec/controllers/projects/boards_controller_spec.rb
+28
-9
No files found.
app/controllers/projects/boards_controller.rb
View file @
723ed9cc
...
...
@@ -9,13 +9,20 @@ class Projects::BoardsController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
@boards
.
as_json
(
only:
[
:id
,
:name
]
)
render
json:
serialize_as_json
(
@boards
)
end
end
end
def
show
::
Boards
::
CreateService
.
new
(
project
,
current_user
).
execute
@board
=
project
.
boards
.
find
(
params
[
:id
])
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
serialize_as_json
(
@board
)
end
end
end
private
...
...
@@ -23,4 +30,8 @@ class Projects::BoardsController < Projects::ApplicationController
def
authorize_read_board!
return
access_denied!
unless
can?
(
current_user
,
:read_board
,
project
)
end
def
serialize_as_json
(
resource
)
resource
.
as_json
(
only:
[
:id
,
:name
])
end
end
spec/controllers/projects/boards_controller_spec.rb
View file @
723ed9cc
...
...
@@ -57,16 +57,24 @@ describe Projects::BoardsController do
end
describe
'GET show'
do
it
'creates a new board when project does not have one'
do
expect
{
read_board
}.
to
change
(
Board
,
:count
).
by
(
1
)
end
let!
(
:board
)
{
create
(
:board
,
project:
project
)
}
it
'renders HTML template'
do
read_board
context
'when format is HTML'
do
it
'renders template'
do
read_board
board:
board
expect
(
response
).
to
render_template
:show
expect
(
response
.
content_type
).
to
eq
'text/html'
end
end
context
'when format is JSON'
do
it
'returns project board'
do
read_board
board:
board
,
format: :json
expect
(
response
).
to
match_response_schema
(
'board'
)
end
end
context
'with unauthorized user'
do
before
do
...
...
@@ -74,16 +82,27 @@ describe Projects::BoardsController do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:read_board
,
project
).
and_return
(
false
)
end
it
'returns a successful 404 response'
do
read_board
it
'returns a not found 404 response'
do
read_board
board:
board
expect
(
response
).
to
have_http_status
(
404
)
end
end
context
'when board does not belong to project'
do
it
'returns a not found 404 response'
do
another_board
=
create
(
:board
)
read_board
board:
another_board
expect
(
response
).
to
have_http_status
(
404
)
end
end
def
read_board
(
format: :html
)
def
read_board
(
board
:,
format: :html
)
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
board
.
to_param
,
format:
format
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