Skip to content
Snippets Groups Projects
Commit fcd46c1a authored by Toon Claes's avatar Toon Claes
Browse files

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.
parent 132cd009
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment