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
Show 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'
...
@@ -2,6 +2,7 @@ require 'spec_helper'
describe
Projects
::
BoardListsController
do
describe
Projects
::
BoardListsController
do
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:project
)
{
create
(
:project_with_board
)
}
let
(
:board
)
{
project
.
board
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
...
@@ -14,19 +15,13 @@ describe Projects::BoardListsController do
...
@@ -14,19 +15,13 @@ describe Projects::BoardListsController do
let
(
:label
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
let
(
:label
)
{
create
(
:label
,
project:
project
,
name:
'Development'
)
}
it
'returns a successful 200 response'
do
it
'returns a successful 200 response'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
create_board_list
label_id:
label
.
id
project_id:
project
.
to_param
,
list:
{
label_id:
label
.
id
},
format: :json
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
end
end
it
'returns the created list'
do
it
'returns the created list'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
create_board_list
label_id:
label
.
id
project_id:
project
.
to_param
,
list:
{
label_id:
label
.
id
},
format: :json
expect
(
response
).
to
match_response_schema
(
'list'
)
expect
(
response
).
to
match_response_schema
(
'list'
)
end
end
...
@@ -34,10 +29,7 @@ describe Projects::BoardListsController do
...
@@ -34,10 +29,7 @@ describe Projects::BoardListsController do
context
'with invalid params'
do
context
'with invalid params'
do
it
'returns an error'
do
it
'returns an error'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
create_board_list
label_id:
nil
project_id:
project
.
to_param
,
list:
{
label_id:
nil
},
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
parsed_response
=
JSON
.
parse
(
response
.
body
)
...
@@ -45,29 +37,28 @@ describe Projects::BoardListsController do
...
@@ -45,29 +37,28 @@ describe Projects::BoardListsController do
expect
(
response
).
to
have_http_status
(
422
)
expect
(
response
).
to
have_http_status
(
422
)
end
end
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
end
describe
'PATCH #update'
do
describe
'PATCH #update'
do
let!
(
:planning
)
{
create
(
:list
,
board:
project
.
board
,
position:
1
)
}
let!
(
:planning
)
{
create
(
:list
,
board:
board
,
position:
1
)
}
let!
(
:development
)
{
create
(
:list
,
board:
project
.
board
,
position:
2
)
}
let!
(
:development
)
{
create
(
:list
,
board:
board
,
position:
2
)
}
context
'with valid position'
do
context
'with valid position'
do
it
'returns a successful 200 response'
do
it
'returns a successful 200 response'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
move
list:
planning
,
position:
2
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
list:
{
position:
2
},
format: :json
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
end
end
it
'moves the list to the desired position'
do
it
'moves the list to the desired position'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
move
list:
planning
,
position:
2
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
list:
{
position:
2
},
format: :json
expect
(
planning
.
reload
.
position
).
to
eq
2
expect
(
planning
.
reload
.
position
).
to
eq
2
end
end
...
@@ -75,11 +66,7 @@ describe Projects::BoardListsController do
...
@@ -75,11 +66,7 @@ describe Projects::BoardListsController do
context
'with invalid position'
do
context
'with invalid position'
do
it
'returns a unprocessable entity 422 response'
do
it
'returns a unprocessable entity 422 response'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
move
list:
planning
,
position:
6
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
list:
{
position:
6
},
format: :json
expect
(
response
).
to
have_http_status
(
422
)
expect
(
response
).
to
have_http_status
(
422
)
end
end
...
@@ -87,49 +74,49 @@ describe Projects::BoardListsController do
...
@@ -87,49 +74,49 @@ describe Projects::BoardListsController do
context
'with invalid list id'
do
context
'with invalid list id'
do
it
'returns a not found 404 response'
do
it
'returns a not found 404 response'
do
patch
:update
,
namespace_id:
project
.
namespace
.
to_param
,
move
list:
999
,
position:
2
project_id:
project
.
to_param
,
id:
999
,
list:
{
position:
2
},
format: :json
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
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
end
describe
'DELETE #destroy'
do
describe
'DELETE #destroy'
do
context
'with valid list id'
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
it
'returns a successful 200 response'
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
to_param
,
remove_board_list
list:
planning
project_id:
project
.
to_param
,
id:
planning
.
to_param
,
format: :json
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
end
end
it
'removes list from board'
do
it
'removes list from board'
do
expect
do
expect
{
remove_board_list
list:
planning
}.
to
change
(
board
.
lists
,
:size
).
by
(
-
1
)
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
)
end
end
end
end
context
'with invalid list id'
do
context
'with invalid list id'
do
it
'returns a not found 404 response'
do
it
'returns a not found 404 response'
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
to_param
,
remove_board_list
list:
999
project_id:
project
.
to_param
,
id:
999
,
format: :json
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
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
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