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
64d75595
Commit
64d75595
authored
Aug 02, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor spec for Projects::BoardListsController
parent
75f0bc4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
49 deletions
+36
-49
spec/controllers/projects/board_lists_controller_spec.rb
spec/controllers/projects/board_lists_controller_spec.rb
+36
-49
No files found.
spec/controllers/projects/board_lists_controller_spec.rb
View file @
64d75595
...
...
@@ -2,6 +2,7 @@ require 'spec_helper'
describe
Projects
::
BoardListsController
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:board
)
{
project
.
board
}
let
(
:user
)
{
create
(
:user
)
}
before
do
...
...
@@ -14,19 +15,13 @@ describe Projects::BoardListsController do
let
(
:label
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
it
'returns a successful 200 response'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
label
.
id
},
format: :json
create_board_list
label_id:
label
.
id
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns the created list'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
label
.
id
},
format: :json
create_board_list
label_id:
label
.
id
expect
(
response
).
to
match_response_schema
(
'list'
)
end
...
...
@@ -34,10 +29,7 @@ describe Projects::BoardListsController do
context
'with invalid params'
do
it
'returns an error'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
nil
},
format: :json
create_board_list
label_id:
nil
parsed_response
=
JSON
.
parse
(
response
.
body
)
...
...
@@ -45,29 +37,28 @@ describe Projects::BoardListsController do
expect
(
response
).
to
have_http_status
(
422
)
end
end
def
create_board_list
(
label_id
:)
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
list:
{
label_id:
label_id
},
format: :json
end
end
describe
'PATCH #update'
do
let!
(
:planning
)
{
create
(
:list
,
board:
project
.
board
,
position:
1
)
}
let!
(
:development
)
{
create
(
:list
,
board:
project
.
board
,
position:
2
)
}
let!
(
:planning
)
{
create
(
:list
,
board:
board
,
position:
1
)
}
let!
(
:development
)
{
create
(
:list
,
board:
board
,
position:
2
)
}
context
'with valid position'
do
it
'returns a successful 200 response'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
list:
{
position:
2
},
format: :json
move
list:
planning
,
position:
2
expect
(
response
).
to
have_http_status
(
200
)
end
it
'moves the list to the desired position'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
list:
{
position:
2
},
format: :json
move
list:
planning
,
position:
2
expect
(
planning
.
reload
.
position
).
to
eq
2
end
...
...
@@ -75,11 +66,7 @@ describe Projects::BoardListsController do
context
'with invalid position'
do
it
'returns a unprocessable entity 422 response'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
list:
{
position:
6
},
format: :json
move
list:
planning
,
position:
6
expect
(
response
).
to
have_http_status
(
422
)
end
...
...
@@ -87,49 +74,49 @@ describe Projects::BoardListsController do
context
'with invalid list id'
do
it
'returns a not found 404 response'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
999
,
list:
{
position:
2
},
format: :json
move
list:
999
,
position:
2
expect
(
response
).
to
have_http_status
(
404
)
end
end
def
move
(
list
:,
position
:)
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
list
.
to_param
,
list:
{
position:
position
},
format: :json
end
end
describe
'DELETE #destroy'
do
context
'with valid list id'
do
let!
(
:planning
)
{
create
(
:list
,
board:
project
.
board
,
position:
1
)
}
let!
(
:planning
)
{
create
(
:list
,
board:
board
,
position:
1
)
}
it
'returns a successful 200 response'
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
format: :json
remove_board_list
list:
planning
expect
(
response
).
to
have_http_status
(
200
)
end
it
'removes list from board'
do
expect
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
format: :json
end
.
to
change
(
project
.
board
.
lists
,
:size
).
by
(
-
1
)
expect
{
remove_board_list
list:
planning
}.
to
change
(
board
.
lists
,
:size
).
by
(
-
1
)
end
end
context
'with invalid list id'
do
it
'returns a not found 404 response'
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
999
,
format: :json
remove_board_list
list:
999
expect
(
response
).
to
have_http_status
(
404
)
end
end
def
remove_board_list
(
list
)
delete
:destroy
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
list
.
to_param
,
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