Commit eaa91cbe authored by Grzegorz Bizon's avatar Grzegorz Bizon

Fix error when CI job variables not specified

parent faee4763
...@@ -54,7 +54,7 @@ module Ci ...@@ -54,7 +54,7 @@ module Ci
job = @jobs[name.to_sym] job = @jobs[name.to_sym]
return [] unless job return [] unless job
job.fetch(:variables, []) job[:variables] || []
end end
private private
......
...@@ -465,6 +465,7 @@ module Ci ...@@ -465,6 +465,7 @@ module Ci
end end
context 'when syntax is incorrect' do context 'when syntax is incorrect' do
context 'when variables defined but invalid' do
it 'raises error' do it 'raises error' do
variables = [:KEY1, 'value1', :KEY2, 'value2'] variables = [:KEY1, 'value1', :KEY2, 'value2']
...@@ -480,6 +481,27 @@ module Ci ...@@ -480,6 +481,27 @@ module Ci
/job: variables should be a map/) /job: variables should be a map/)
end end
end end
context 'when variables key defined but value not specified' do
it 'returns empty array' do
config = YAML.dump(
{ before_script: ['pwd'],
rspec: {
variables: nil,
script: 'rspec' }
})
config_processor = GitlabCiYamlProcessor.new(config, path)
##
# TODO, in next version of CI configuration processor this
# should be invalid configuration, see #18775 and #15060
#
expect(config_processor.job_variables(:rspec))
.to be_an_instance_of(Array).and be_empty
end
end
end
end end
context 'when job variables are not defined' do context 'when job variables are not defined' 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