Commit 1f320edb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Minor refactorings in new CI configuration classes

parent 29b96d92
......@@ -91,6 +91,11 @@ module Ci
{
stage_idx: @stages.index(job[:stage]),
stage: job[:stage],
##
# Refactoring note:
# - before script behaves differently than after script
# - after script returns an array of commands
# - before script should be a concatenated command
commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"),
tag_list: job[:tags] || [],
name: name,
......
......@@ -52,7 +52,7 @@ module Gitlab
factory = Node::Factory.new(entry_class)
.with(description: metadata[:description])
(@nodes ||= {}).merge!(symbol => factory)
(@nodes ||= {}).merge!(symbol.to_sym => factory)
end
end
end
......
......@@ -44,8 +44,7 @@ module Gitlab
end
def errors
@validator.full_errors +
nodes.map(&:errors).flatten
@validator.messages + nodes.flat_map(&:errors)
end
def value
......
......@@ -11,7 +11,7 @@ module Gitlab
@node = node
end
def full_errors
def messages
errors.full_messages.map do |error|
"#{@node.key} #{error}".humanize
end
......
......@@ -19,7 +19,7 @@ describe Gitlab::Ci::Config::Node::Validator do
it 'returns no errors' do
validator_instance.validate
expect(validator_instance.full_errors).to be_empty
expect(validator_instance.messages).to be_empty
end
end
......@@ -36,7 +36,7 @@ describe Gitlab::Ci::Config::Node::Validator do
it 'returns errors' do
validator_instance.validate
expect(validator_instance.full_errors).not_to be_empty
expect(validator_instance.messages).not_to be_empty
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