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
fe3f1657
Commit
fe3f1657
authored
Oct 04, 2016
by
Douglas Barbosa Alexandre
Committed by
Phil Hughes
Oct 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests to Projects::Boards::IssuesController#create action
parent
97ec0c05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
7 deletions
+57
-7
spec/controllers/projects/boards/issues_controller_spec.rb
spec/controllers/projects/boards/issues_controller_spec.rb
+57
-7
No files found.
spec/controllers/projects/boards/issues_controller_spec.rb
View file @
fe3f1657
...
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
Projects
::
Boards
::
IssuesController
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
)
}
let
(
:planning
)
{
create
(
:label
,
project:
project
,
name:
'Planning'
)
}
let
(
:development
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
...
...
@@ -12,6 +13,7 @@ describe Projects::Boards::IssuesController do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
guest
,
:guest
]
end
describe
'GET index'
do
...
...
@@ -61,6 +63,60 @@ describe Projects::Boards::IssuesController do
end
end
describe
'POST create'
do
context
'with valid params'
do
it
'returns a successful 200 response'
do
create_issue
user:
user
,
list:
list1
,
title:
'New issue'
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns the created issue'
do
create_issue
user:
user
,
list:
list1
,
title:
'New issue'
expect
(
response
).
to
match_response_schema
(
'issue'
)
end
end
context
'with invalid params'
do
context
'when title is nil'
do
it
'returns an unprocessable entity 422 response'
do
create_issue
user:
user
,
list:
list1
,
title:
nil
expect
(
response
).
to
have_http_status
(
422
)
end
end
context
'when list does not belongs to project board'
do
it
'returns a not found 404 response'
do
list
=
create
(
:list
)
create_issue
user:
user
,
list:
list
,
title:
'New issue'
expect
(
response
).
to
have_http_status
(
404
)
end
end
end
context
'with unauthorized user'
do
it
'returns a forbidden 403 response'
do
create_issue
user:
guest
,
list:
list1
,
title:
'New issue'
expect
(
response
).
to
have_http_status
(
403
)
end
end
def
create_issue
(
user
:,
list
:,
title
:)
sign_in
(
user
)
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list_id:
list
.
to_param
,
issue:
{
title:
title
},
format: :json
end
end
describe
'PATCH update'
do
let
(
:issue
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
planning
])
}
...
...
@@ -93,13 +149,7 @@ describe Projects::Boards::IssuesController do
end
context
'with unauthorized user'
do
let
(
:guest
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
guest
,
:guest
]
end
it
'returns a successful 403 response'
do
it
'returns a forbidden 403 response'
do
move
user:
guest
,
issue:
issue
,
from_list_id:
list1
.
id
,
to_list_id:
list2
.
id
expect
(
response
).
to
have_http_status
(
403
)
...
...
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