Execute quick actions when creating MR from issue
In CE, this does nothing - the `MergeRequests::BuildService` will, at the time of writing, never return a description for this case. In EE, a project can have a default MR template, which will be returned by the service. Previously we were only using the description passed in the params, ignoring any already set on the object. Now we fall back to the one set on the object if there was none in the params, allowing quick actions to be executed from default MR templates when creating an MR from an issue.
This commit is contained in:
parent
9429e8ac60
commit
b1e3cb24fa
|
@ -106,12 +106,14 @@ class IssuableBaseService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge_quick_actions_into_params!(issuable)
|
def merge_quick_actions_into_params!(issuable)
|
||||||
|
original_description = params.fetch(:description, issuable.description)
|
||||||
|
|
||||||
description, command_params =
|
description, command_params =
|
||||||
QuickActions::InterpretService.new(project, current_user)
|
QuickActions::InterpretService.new(project, current_user)
|
||||||
.execute(params[:description], issuable)
|
.execute(original_description, issuable)
|
||||||
|
|
||||||
# Avoid a description already set on an issuable to be overwritten by a nil
|
# Avoid a description already set on an issuable to be overwritten by a nil
|
||||||
params[:description] = description if params.key?(:description)
|
params[:description] = description if description
|
||||||
|
|
||||||
params.merge!(command_params)
|
params.merge!(command_params)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Execute quick actions (if present) when creating MR from issue
|
||||||
|
merge_request: 15810
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -100,5 +100,17 @@ describe MergeRequests::CreateFromIssueService do
|
||||||
|
|
||||||
expect(result[:merge_request].target_branch).to eq(project.default_branch)
|
expect(result[:merge_request].target_branch).to eq(project.default_branch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'executes quick actions if the build service sets them in the description' do
|
||||||
|
allow(service).to receive(:merge_request).and_wrap_original do |m, *args|
|
||||||
|
m.call(*args).tap do |merge_request|
|
||||||
|
merge_request.description = "/assign #{user.to_reference}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result = service.execute
|
||||||
|
|
||||||
|
expect(result[:merge_request].assignee).to eq(user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue