Commit 56af0bfd authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'refactor-pipeline-errors_message-ce' into 'master'

CE Port: Refactor pipeline errors_message

See merge request gitlab-org/gitlab-ce!30116
parents 7b315ed6 93be669e
......@@ -790,6 +790,10 @@ module Ci
stages.find_by!(name: name)
end
def error_messages
errors ? errors.full_messages.to_sentence : ""
end
private
def ci_yaml_from_repo
......
......@@ -65,7 +65,7 @@ module Ci
def execute!(*args, &block)
execute(*args, &block).tap do |pipeline|
unless pipeline.persisted?
raise CreateError, pipeline.errors.full_messages.join(',')
raise CreateError, pipeline.error_messages
end
end
end
......
......@@ -2998,4 +2998,28 @@ describe Ci::Pipeline, :mailer do
end
end
end
describe '#error_messages' do
subject { pipeline.error_messages }
before do
pipeline.valid?
end
context 'when pipeline has errors' do
let(:pipeline) { build(:ci_pipeline, sha: nil, ref: nil) }
it 'returns the full error messages' do
is_expected.to eq("Sha can't be blank and Ref can't be blank")
end
end
context 'when pipeline does not have errors' do
let(:pipeline) { build(:ci_pipeline) }
it 'returns empty string' do
is_expected.to be_empty
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