diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb
index c1bcff34b6f..bc4febf61f0 100644
--- a/app/services/quick_actions/interpret_service.rb
+++ b/app/services/quick_actions/interpret_service.rb
@@ -269,21 +269,21 @@ module QuickActions
end
desc 'Copy labels and milestone from other issue or merge request'
- explanation do |issuable_id|
- "Copy labels and milestone from issue or merge_request #{issuable_id}."
+ explanation do |source_issuable|
+ "Copy labels and milestone from #{source_issuable.to_reference}."
end
params '#issue | !merge_request'
condition do
issuable.persisted? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
end
- command :copy_metadata do |issuable_id|
- source_issuable = extract_references(issuable_id, :issue).first
- source_issuable ||= extract_references(issuable_id, :merge_request).first
-
+ parse_params do |issuable_param|
+ extract_references(issuable_param, :issue).first ||
+ extract_references(issuable_param, :merge_request).first
+ end
+ command :copy_metadata do |source_issuable|
if source_issuable.present? && source_issuable.project.id == issuable.project.id
@updates[:add_label_ids] = source_issuable.labels.map(&:id)
-
@updates[:milestone_id] = source_issuable.milestone.id if source_issuable.milestone
end
end
diff --git a/doc/user/project/quick_actions.md b/doc/user/project/quick_actions.md
index 3e3b699edc4..2f4ed3493c2 100644
--- a/doc/user/project/quick_actions.md
+++ b/doc/user/project/quick_actions.md
@@ -38,7 +38,7 @@ do.
| `/award :emoji:` | Toggle award for :emoji: |
| `/board_move ~column` | Move issue to column on the board |
| `/duplicate #issue` | Closes this issue and marks it as a duplicate of another issue |
-| `/move path/to/project` | Moves issue to another project |
-| `/tableflip` | Append the comment with `(╯°□°)╯︵ ┻━┻` |
-| `/shrug` | Append the comment with `¯\_(ツ)_/¯` |
-| /copy_metadata #issue | !merge_request
| Copy labels and milestone from other issue or merge request |
+| `/move path/to/project` | Moves issue to another project |
+| `/tableflip` | Append the comment with `(╯°□°)╯︵ ┻━┻` |
+| `/shrug` | Append the comment with `¯\_(ツ)_/¯` |
+| /copy_metadata #issue | !merge_request
| Copy labels and milestone from other issue or merge request |
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 4aad2aaef79..bd835a1fca6 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -775,8 +775,8 @@ describe QuickActions::InterpretService do
end
context '/copy_metadata command' do
- let!(:todo_label) { create(:label, project: project, title: 'To Do') }
- let!(:inreview_label) { create(:label, project: project, title: 'In Review') }
+ let(:todo_label) { create(:label, project: project, title: 'To Do') }
+ let(:inreview_label) { create(:label, project: project, title: 'In Review') }
it_behaves_like 'empty command' do
let(:content) { '/copy_metadata' }
@@ -799,6 +799,17 @@ describe QuickActions::InterpretService do
end
end
+ context 'when more than one issuable is passed' do
+ it_behaves_like 'copy_metadata command' do
+ let(:source_issuable) { create(:labeled_issue, project: project, labels: [inreview_label, todo_label]) }
+ let(:other_label) { create(:label, project: project, title: 'Other') }
+ let(:other_source_issuable) { create(:labeled_issue, project: project, labels: [other_label]) }
+
+ let(:content) { "/copy_metadata #{source_issuable.to_reference} #{other_source_issuable.to_reference}" }
+ let(:issuable) { issue }
+ end
+ end
+
context 'cross project references' do
it_behaves_like 'empty command' do
let(:other_project) { create(:project, :public) }