Commit 163e5b7a authored by Alex Pooley's avatar Alex Pooley

Merge branch 'fix_error_for_empty_changelog' into 'master'

Fix NoMethodError for empty changelog

See merge request gitlab-org/gitlab!79481
parents 3fe7e89a aedbd810
...@@ -37,7 +37,7 @@ module Gitlab ...@@ -37,7 +37,7 @@ module Gitlab
attr_accessor :date_format, :categories, :template, :tag_regex, :always_credit_user_ids attr_accessor :date_format, :categories, :template, :tag_regex, :always_credit_user_ids
def self.from_git(project, user = nil) def self.from_git(project, user = nil)
if (yaml = project.repository.changelog_config) if (yaml = project.repository.changelog_config.presence)
from_hash(project, YAML.safe_load(yaml), user) from_hash(project, YAML.safe_load(yaml), user)
else else
new(project) new(project)
......
...@@ -31,6 +31,20 @@ RSpec.describe Gitlab::Changelog::Config do ...@@ -31,6 +31,20 @@ RSpec.describe Gitlab::Changelog::Config do
described_class.from_git(project) described_class.from_git(project)
end end
context 'when changelog is empty' do
it 'returns the default configuration' do
allow(project.repository)
.to receive(:changelog_config)
.and_return("")
expect(described_class)
.to receive(:new)
.with(project)
described_class.from_git(project)
end
end
end end
describe '.from_hash' do describe '.from_hash' do
......
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