Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-06-20 23:02:41 +0300
committerToon Claes <toon@gitlab.com>2017-06-20 23:02:41 +0300
commit2194856fcf45c9556067a7c2fb6db677f9388c61 (patch)
tree67469825373226fc7ce06b62d7b0cc1194d1fd01 /app/services/quick_actions
parent451e25532ff43de8151b71ced8246f709c08bf92 (diff)
Ensure /reassign does not assign multiple users
Set the assignee to last user in the array if multiple assignees aren't allowed. Also, use `parse_params` where possible.
Diffstat (limited to 'app/services/quick_actions')
-rw-r--r--app/services/quick_actions/interpret_service.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb
index df13976fb3b..e4dfe87e614 100644
--- a/app/services/quick_actions/interpret_service.rb
+++ b/app/services/quick_actions/interpret_service.rb
@@ -133,10 +133,11 @@ module QuickActions
issuable.assignees.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
- command :unassign do |unassign_param = nil|
+ parse_params do |unassign_param|
# When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed
- users = extract_users(unassign_param) if issuable.allows_multiple_assignees?
-
+ extract_users(unassign_param) if issuable.allows_multiple_assignees?
+ end
+ command :unassign do |users = nil|
@updates[:assignee_ids] =
if users&.any?
issuable.assignees.pluck(:id) - users.map(&:id)
@@ -159,8 +160,16 @@ module QuickActions
issuable.persisted? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
- command :reassign do |unassign_param|
- @updates[:assignee_ids] = extract_users(unassign_param).map(&:id)
+ parse_params do |assignee_param|
+ extract_users(assignee_param)
+ end
+ command :reassign do |users|
+ @updates[:assignee_ids] =
+ if issuable.allows_multiple_assignees?
+ users.map(&:id)
+ else
+ [users.last.id]
+ end
end
desc 'Set milestone'