Backport /reassign quick command
The /reassign quick command works even when no multiple assignees are allowed of there isn't any assignee yet. So for consistency, it's also be backported to CE. But it functions the same as the /assign quick action.
This commit is contained in:
parent
132cd0092d
commit
fcd46c1af4
|
@ -150,6 +150,24 @@ module QuickActions
|
|||
end
|
||||
end
|
||||
|
||||
desc do
|
||||
"Change assignee#{'(s)' if issuable.allows_multiple_assignees?}"
|
||||
end
|
||||
explanation do |users|
|
||||
users = issuable.allows_multiple_assignees? ? users : users.take(1)
|
||||
"Change #{'assignee'.pluralize(users.size)} to #{users.map(&:to_reference).to_sentence}."
|
||||
end
|
||||
params do
|
||||
issuable.allows_multiple_assignees? ? '@user1 @user2' : '@user'
|
||||
end
|
||||
condition do
|
||||
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)
|
||||
end
|
||||
|
||||
desc 'Set milestone'
|
||||
explanation do |milestone|
|
||||
"Sets the milestone to #{milestone.to_reference}." if milestone
|
||||
|
|
|
@ -362,7 +362,7 @@ describe QuickActions::InterpretService, services: true do
|
|||
it 'fetches assignee and populates assignee_id if content contains /assign' do
|
||||
_, updates = service.execute(content, issue)
|
||||
|
||||
expect(updates).to eq(assignee_ids: [developer.id])
|
||||
expect(updates[:assignee_ids]).to match_array([developer.id])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -431,6 +431,22 @@ describe QuickActions::InterpretService, services: true do
|
|||
end
|
||||
end
|
||||
|
||||
context 'reassign command' do
|
||||
let(:content) { '/reassign' }
|
||||
|
||||
context 'Issue' do
|
||||
it 'reassigns user if content contains /reassign @user' do
|
||||
user = create(:user)
|
||||
|
||||
issue.update(assignee_ids: [developer.id])
|
||||
|
||||
_, updates = service.execute("/reassign @#{user.username}", issue)
|
||||
|
||||
expect(updates).to eq(assignee_ids: [user.id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'milestone command' do
|
||||
let(:content) { "/milestone %#{milestone.title}" }
|
||||
let(:issuable) { issue }
|
||||
|
|
Loading…
Reference in New Issue