Commit 1f324864 authored by Grzegorz Bizon's avatar Grzegorz Bizon 🔴

Make CI config return empty array if no job variables

parent 3dec6e26
......@@ -45,8 +45,11 @@ module Ci
end
def job_variables(name)
job = @jobs[name.to_sym]
job ? job[:variables] : []
if job = @jobs[name.to_sym]
job[:variables] || []
else
[]
end
end
private
......
......@@ -380,6 +380,18 @@ module Ci
expect(config.job_variables(:rspec)).to eq job_variables
end
end
context 'when job variables are not defined' do
it 'returns empty array' do
config = YAML.dump({
before_script: ["pwd"],
rspec: { script: "rspec" }
})
config_processor = GitlabCiYamlProcessor.new(config, path)
expect(config_processor.job_variables(:rspec)).to eq []
end
end
end
describe "When" 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