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
ecf4c10e
Commit
ecf4c10e
authored
Oct 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add index action to Projects::BoardsController to return project boards
parent
b4b8e0ec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
4 deletions
+76
-4
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+12
-3
app/views/projects/boards/index.html.haml
app/views/projects/boards/index.html.haml
+0
-0
config/routes/project.rb
config/routes/project.rb
+1
-1
spec/controllers/projects/boards_controller_spec.rb
spec/controllers/projects/boards_controller_spec.rb
+47
-0
spec/fixtures/api/schemas/board.json
spec/fixtures/api/schemas/board.json
+12
-0
spec/fixtures/api/schemas/boards.json
spec/fixtures/api/schemas/boards.json
+4
-0
No files found.
app/controllers/projects/boards_controller.rb
View file @
ecf4c10e
class
Projects::BoardsController
<
Projects
::
ApplicationController
include
IssuableCollections
respond_to
:html
before_action
:authorize_read_board!
,
only:
[
:show
]
before_action
:authorize_read_board!
,
only:
[
:index
,
:show
]
def
index
@boards
=
::
Boards
::
ListService
.
new
(
project
,
current_user
).
execute
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
@boards
.
as_json
(
only:
[
:id
,
:name
])
end
end
end
def
show
::
Boards
::
CreateService
.
new
(
project
,
current_user
).
execute
...
...
app/views/projects/boards/index.html.haml
0 → 100644
View file @
ecf4c10e
config/routes/project.rb
View file @
ecf4c10e
...
...
@@ -416,7 +416,7 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only:
end
end
resource
:board
,
only:
[
:show
]
do
resource
s
:boards
,
only:
[
:index
,
:show
]
do
scope
module: :boards
do
resources
:issues
,
only:
[
:update
]
...
...
spec/controllers/projects/boards_controller_spec.rb
View file @
ecf4c10e
...
...
@@ -9,6 +9,53 @@ describe Projects::BoardsController do
sign_in
(
user
)
end
describe
'GET index'
do
it
'creates a new project board when project does not have one'
do
expect
{
list_boards
}.
to
change
(
project
.
boards
,
:count
).
by
(
1
)
end
context
'when format is HTML'
do
it
'renders template'
do
list_boards
expect
(
response
).
to
render_template
:index
expect
(
response
.
content_type
).
to
eq
'text/html'
end
end
context
'when format is JSON'
do
it
'returns a list of project boards'
do
create_list
(
:board
,
2
,
project:
project
)
list_boards
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
parsed_response
.
length
).
to
eq
2
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
,
:read_board
,
project
).
and_return
(
false
)
end
it
'returns a not found 404 response'
do
list_boards
expect
(
response
).
to
have_http_status
(
404
)
end
end
def
list_boards
(
format: :html
)
get
:index
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
format:
format
end
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
)
...
...
spec/fixtures/api/schemas/board.json
0 → 100644
View file @
ecf4c10e
{
"type"
:
"object"
,
"required"
:
[
"id"
,
"name"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"name"
:
{
"type"
:
"string"
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/boards.json
0 → 100644
View file @
ecf4c10e
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"board.json"
}
}
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