Commit e25c5a04 authored by Igor Drozdov's avatar Igor Drozdov

Fix applying suggestions with empty custom message

When the custom suggestion message is cleared,
it's stored as an empty string in db. In this case
we still need to apply default commit message
parent 4816319c
......@@ -96,7 +96,7 @@ module Suggestions
end
def suggestion_commit_message(project)
project.suggestion_commit_message || DEFAULT_SUGGESTION_COMMIT_MESSAGE
project.suggestion_commit_message.presence || DEFAULT_SUGGESTION_COMMIT_MESSAGE
end
def processed_suggestion_commit_message(suggestion)
......
---
title: Fix applying the suggestions with an empty custom message
merge_request: 24144
author:
type: fixed
......@@ -57,10 +57,22 @@ describe Suggestions::ApplyService do
end
context 'is not specified' do
let(:expected_value) { "Apply suggestion to files/ruby/popen.rb" }
context 'is nil' do
let(:message) { nil }
it 'sets default commit message' do
expect(project.repository.commit.message).to eq("Apply suggestion to files/ruby/popen.rb")
expect(project.repository.commit.message).to eq(expected_value)
end
end
context 'is an empty string' do
let(:message) { '' }
it 'sets default commit message' do
expect(project.repository.commit.message).to eq(expected_value)
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