summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2018-08-07 17:29:06 +0000
committerPhil Hughes <me@iamphill.com>2018-08-07 17:29:06 +0000
commitddb14e4098c9b16023cdd25743cb2dfb52481e5a (patch)
tree8e05a389dacf30ec13eb59e975e0c3dfff79003f /lib
parent21c18070283041fb016777493d61b42edac600e5 (diff)
downloadgitlab-ce-ddb14e4098c9b16023cdd25743cb2dfb52481e5a.tar.gz
Backport issue board milestone lists EE changes
Diffstat (limited to 'lib')
-rw-r--r--lib/api/boards.rb6
-rw-r--r--lib/api/boards_responses.rb16
-rw-r--r--lib/api/group_boards.rb6
3 files changed, 19 insertions, 9 deletions
diff --git a/lib/api/boards.rb b/lib/api/boards.rb
index 086d39d5070..0f89414148b 100644
--- a/lib/api/boards.rb
+++ b/lib/api/boards.rb
@@ -71,12 +71,10 @@ module API
success Entities::List
end
params do
- requires :label_id, type: Integer, desc: 'The ID of an existing label'
+ use :list_creation_params
end
post '/lists' do
- unless available_labels_for(user_project).exists?(params[:label_id])
- render_api_error!({ error: 'Label not found!' }, 400)
- end
+ authorize_list_type_resource!
authorize!(:admin_list, user_project)
diff --git a/lib/api/boards_responses.rb b/lib/api/boards_responses.rb
index ead0943a74d..7e873012efe 100644
--- a/lib/api/boards_responses.rb
+++ b/lib/api/boards_responses.rb
@@ -14,7 +14,7 @@ module API
def create_list
create_list_service =
- ::Boards::Lists::CreateService.new(board_parent, current_user, { label_id: params[:label_id] })
+ ::Boards::Lists::CreateService.new(board_parent, current_user, create_list_params)
list = create_list_service.execute(board)
@@ -25,6 +25,10 @@ module API
end
end
+ def create_list_params
+ params.slice(:label_id)
+ end
+
def move_list(list)
move_list_service =
::Boards::Lists::MoveService.new(board_parent, current_user, { position: params[:position].to_i })
@@ -44,6 +48,16 @@ module API
end
end
end
+
+ def authorize_list_type_resource!
+ unless available_labels_for(board_parent).exists?(params[:label_id])
+ render_api_error!({ error: 'Label not found!' }, 400)
+ end
+ end
+
+ params :list_creation_params do
+ requires :label_id, type: Integer, desc: 'The ID of an existing label'
+ end
end
end
end
diff --git a/lib/api/group_boards.rb b/lib/api/group_boards.rb
index aa9fff25fc8..3832cdc10a8 100644
--- a/lib/api/group_boards.rb
+++ b/lib/api/group_boards.rb
@@ -70,12 +70,10 @@ module API
success Entities::List
end
params do
- requires :label_id, type: Integer, desc: 'The ID of an existing label'
+ use :list_creation_params
end
post '/lists' do
- unless available_labels_for(board_parent).exists?(params[:label_id])
- render_api_error!({ error: 'Label not found!' }, 400)
- end
+ authorize_list_type_resource!
authorize!(:admin_list, user_group)