Merge branch 'dm-fix-assign-unassign-quick-actions' into 'master'

Don't ignore first action when assign and unassign quick actions are used in the same comment

See merge request gitlab-org/gitlab-ce!21749
This commit is contained in:
Rémy Coutable 2018-09-26 15:16:20 +00:00
commit 82ea7195cd
2 changed files with 18 additions and 16 deletions

View File

@ -126,18 +126,16 @@ module QuickActions
parse_params do |assignee_param|
extract_users(assignee_param)
end
# rubocop: disable CodeReuse/ActiveRecord
command :assign do |users|
next if users.empty?
@updates[:assignee_ids] =
if issuable.allows_multiple_assignees?
issuable.assignees.pluck(:id) + users.map(&:id)
else
[users.first.id]
end
if issuable.allows_multiple_assignees?
@updates[:assignee_ids] ||= issuable.assignees.map(&:id)
@updates[:assignee_ids] += users.map(&:id)
else
@updates[:assignee_ids] = [users.first.id]
end
end
# rubocop: enable CodeReuse/ActiveRecord
desc do
if issuable.allows_multiple_assignees?
@ -164,16 +162,14 @@ module QuickActions
# When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed
extract_users(unassign_param) if issuable.allows_multiple_assignees?
end
# rubocop: disable CodeReuse/ActiveRecord
command :unassign do |users = nil|
@updates[:assignee_ids] =
if users&.any?
issuable.assignees.pluck(:id) - users.map(&:id)
else
[]
end
if issuable.allows_multiple_assignees? && users&.any?
@updates[:assignee_ids] ||= issuable.assignees.map(&:id)
@updates[:assignee_ids] -= users.map(&:id)
else
@updates[:assignee_ids] = []
end
end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Set milestone'
explanation do |milestone|

View File

@ -0,0 +1,6 @@
---
title: Don't ignore first action when assign and unassign quick actions are used in
the same comment
merge_request: 21749
author:
type: fixed