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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
0fb9210d
Commit
0fb9210d
authored
Aug 01, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoint to allow users to move lists
parent
4f45d113
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
1 deletion
+75
-1
app/controllers/projects/board_lists_controller.rb
app/controllers/projects/board_lists_controller.rb
+22
-0
config/routes.rb
config/routes.rb
+1
-1
spec/controllers/projects/board_lists_controller_spec.rb
spec/controllers/projects/board_lists_controller_spec.rb
+52
-0
No files found.
app/controllers/projects/board_lists_controller.rb
View file @
0fb9210d
class
Projects::BoardListsController
<
Projects
::
ApplicationController
class
Projects::BoardListsController
<
Projects
::
ApplicationController
rescue_from
ActiveRecord
::
RecordNotFound
,
with: :record_not_found
def
create
def
create
list
=
Boards
::
Lists
::
CreateService
.
new
(
project
,
list_params
).
execute
list
=
Boards
::
Lists
::
CreateService
.
new
(
project
,
list_params
).
execute
...
@@ -11,9 +13,29 @@ class Projects::BoardListsController < Projects::ApplicationController
...
@@ -11,9 +13,29 @@ class Projects::BoardListsController < Projects::ApplicationController
end
end
end
end
def
update
service
=
Boards
::
Lists
::
MoveService
.
new
(
project
,
move_params
)
respond_to
do
|
format
|
if
service
.
execute
format
.
json
{
head
:ok
}
else
format
.
json
{
head
:unprocessable_entity
}
end
end
end
private
private
def
record_not_found
(
exception
)
render
json:
{
error:
exception
.
message
},
status: :not_found
end
def
list_params
def
list_params
params
.
require
(
:list
).
permit
(
:label_id
)
params
.
require
(
:list
).
permit
(
:label_id
)
end
end
def
move_params
params
.
require
(
:list
).
permit
(
:position
).
merge
(
id:
params
[
:id
])
end
end
end
config/routes.rb
View file @
0fb9210d
...
@@ -857,7 +857,7 @@ Rails.application.routes.draw do
...
@@ -857,7 +857,7 @@ Rails.application.routes.draw do
end
end
resource
:board
,
only:
[
:show
]
do
resource
:board
,
only:
[
:show
]
do
resources
:lists
,
only:
[
:create
],
controller: :board_lists
resources
:lists
,
only:
[
:create
,
:update
],
controller: :board_lists
end
end
resources
:todos
,
only:
[
:create
]
resources
:todos
,
only:
[
:create
]
...
...
spec/controllers/projects/board_lists_controller_spec.rb
View file @
0fb9210d
...
@@ -46,4 +46,56 @@ describe Projects::BoardListsController do
...
@@ -46,4 +46,56 @@ describe Projects::BoardListsController do
end
end
end
end
end
end
describe
'PATCH #update'
do
let!
(
:planning
)
{
create
(
:list
,
board:
project
.
board
,
position:
1
)
}
let!
(
:development
)
{
create
(
:list
,
board:
project
.
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
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
expect
(
planning
.
reload
.
position
).
to
eq
2
end
end
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
expect
(
response
).
to
have_http_status
(
422
)
end
end
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
expect
(
response
).
to
have_http_status
(
404
)
end
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