Commit 27252abf authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Don't overwrite user's description by default template description

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/220941

**Problem**

When a project has a default description template for merge
requests. Then, it is not possible to set a custom template via push
options or query parameters.

**Solution**

Don't use a default description template when the description is
already defined.
parent 0cfccf25
......@@ -4,15 +4,16 @@ module EE
module MergeRequests
module BuildService
def assign_title_and_description
super
assign_description_from_template
super
end
# Set MR description based on project template
def assign_description_from_template
return unless target_project.feature_available?(:issuable_default_templates) &&
target_project.merge_requests_template.present?
target_project.merge_requests_template.present? &&
merge_request.description.blank?
merge_request.description = target_project.merge_requests_template
......
---
title: "Don't overwrite user's description by default template description"
merge_request: 40609
author:
type: fixed
......@@ -40,6 +40,14 @@ RSpec.describe MergeRequests::BuildService do
it 'does not set the MR description from template' do
expect(merge_request.description).not_to eq(template)
end
context 'when description is provided' do
let(:description) { 'Description' }
it "sets the user's description" do
expect(merge_request.description).to eq(description)
end
end
end
context 'issuable default templates feature available' do
......@@ -50,6 +58,14 @@ RSpec.describe MergeRequests::BuildService do
it 'sets the MR description from template' do
expect(merge_request.description).to eq(template)
end
context 'when description is provided' do
let(:description) { 'Description' }
it "prefers user's description to the default template" do
expect(merge_request.description).to eq(description)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment