Commit 2194856f authored by Toon Claes's avatar Toon Claes

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.
parent 451e2553
...@@ -133,10 +133,11 @@ module QuickActions ...@@ -133,10 +133,11 @@ module QuickActions
issuable.assignees.any? && issuable.assignees.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end 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 # 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] = @updates[:assignee_ids] =
if users&.any? if users&.any?
issuable.assignees.pluck(:id) - users.map(&:id) issuable.assignees.pluck(:id) - users.map(&:id)
...@@ -159,8 +160,16 @@ module QuickActions ...@@ -159,8 +160,16 @@ module QuickActions
issuable.persisted? && issuable.persisted? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end end
command :reassign do |unassign_param| parse_params do |assignee_param|
@updates[:assignee_ids] = extract_users(unassign_param).map(&:id) 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 end
desc 'Set milestone' desc 'Set milestone'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment