Commit deb0a4ea authored by charlie ablett's avatar charlie ablett

Merge branch '220941_fix_description_for_push_options' into 'master'

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

Closes #220941

See merge request gitlab-org/gitlab!40609
parents c09f0508 27252abf
...@@ -4,15 +4,16 @@ module EE ...@@ -4,15 +4,16 @@ module EE
module MergeRequests module MergeRequests
module BuildService module BuildService
def assign_title_and_description def assign_title_and_description
super
assign_description_from_template assign_description_from_template
super
end end
# Set MR description based on project template # Set MR description based on project template
def assign_description_from_template def assign_description_from_template
return unless target_project.feature_available?(:issuable_default_templates) && 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 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 ...@@ -40,6 +40,14 @@ RSpec.describe MergeRequests::BuildService do
it 'does not set the MR description from template' do it 'does not set the MR description from template' do
expect(merge_request.description).not_to eq(template) expect(merge_request.description).not_to eq(template)
end 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 end
context 'issuable default templates feature available' do context 'issuable default templates feature available' do
...@@ -50,6 +58,14 @@ RSpec.describe MergeRequests::BuildService do ...@@ -50,6 +58,14 @@ RSpec.describe MergeRequests::BuildService do
it 'sets the MR description from template' do it 'sets the MR description from template' do
expect(merge_request.description).to eq(template) expect(merge_request.description).to eq(template)
end 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 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