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
e1998844
Commit
e1998844
authored
Aug 01, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Projects::BoardsController#show returns a list of board lists
parent
bddb2f93
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
7 deletions
+79
-7
app/controllers/projects/boards_controller.rb
app/controllers/projects/boards_controller.rb
+2
-1
spec/controllers/projects/boards_controller_spec.rb
spec/controllers/projects/boards_controller_spec.rb
+33
-6
spec/fixtures/api/schemas/list.json
spec/fixtures/api/schemas/list.json
+35
-0
spec/support/api/schema_matcher.rb
spec/support/api/schema_matcher.rb
+9
-0
No files found.
app/controllers/projects/boards_controller.rb
View file @
e1998844
class
Projects::BoardsController
<
Projects
::
ApplicationController
def
show
Boards
::
CreateService
.
new
(
project
).
execute
board
=
Boards
::
CreateService
.
new
(
project
).
execute
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
board
.
lists
.
as_json
(
only:
[
:id
,
:list_type
,
:position
],
methods:
[
:title
],
include:
{
label:
{
only:
[
:id
,
:title
,
:color
]
}
})
}
end
end
end
spec/controllers/projects/boards_controller_spec.rb
View file @
e1998844
...
...
@@ -10,10 +10,13 @@ describe Projects::BoardsController do
end
describe
'GET #show'
do
it
'creates a new board when project does not have one'
do
context
'when project does not have a board'
do
it
'creates a new board'
do
expect
{
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
}.
to
change
(
Board
,
:count
).
by
(
1
)
end
end
context
'when format is HTML'
do
it
'renders HTML template'
do
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
...
...
@@ -21,4 +24,28 @@ describe Projects::BoardsController do
expect
(
response
.
content_type
).
to
eq
'text/html'
end
end
context
'when format is JSON'
do
it
'returns a successful 200 response'
do
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
format: :json
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
.
content_type
).
to
eq
'application/json'
end
it
'returns a list of board lists'
do
board
=
project
.
create_board
create
(
:backlog_list
,
board:
board
)
create
(
:list
,
board:
board
)
create
(
:done_list
,
board:
board
)
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'list'
,
array:
true
)
expect
(
parsed_response
.
length
).
to
eq
3
end
end
end
end
spec/fixtures/api/schemas/list.json
0 → 100644
View file @
e1998844
{
"type"
:
"object"
,
"required"
:
[
"id"
,
"list_type"
,
"title"
,
"position"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"list_type"
:
{
"type"
:
"string"
,
"enum"
:
[
"backlog"
,
"label"
,
"done"
]
},
"label"
:
{
"type"
:
[
"object"
],
"required"
:
[
"id"
,
"color"
,
"title"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"color"
:
{
"type"
:
"string"
,
"pattern"
:
"^#[0-9A-Fa-f]{3}{1,2}+$"
},
"title"
:
{
"type"
:
"string"
}
}
},
"title"
:
{
"type"
:
"string"
},
"position"
:
{
"type"
:
[
"integer"
,
"null"
]
}
},
"additionalProperties"
:
false
}
spec/support/api/schema_matcher.rb
0 → 100644
View file @
e1998844
RSpec
::
Matchers
.
define
:match_response_schema
do
|
schema
,
options
=
{}
|
match
do
|
response
|
schema_directory
=
"
#{
Dir
.
pwd
}
/spec/fixtures/api/schemas"
schema_path
=
"
#{
schema_directory
}
/
#{
schema
}
.json"
list
=
options
.
fetch
(
:array
,
false
)
JSON
::
Validator
.
validate!
(
schema_path
,
response
.
body
,
list:
list
)
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