Commit cf53d798 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extract jobs config to separate key in config hash

parent 06c7d6f3
......@@ -36,6 +36,22 @@ module Gitlab
helpers :before_script, :image, :services, :after_script,
:variables, :stages, :types, :cache
def initialize(config)
return super(config) unless config.is_a?(Hash)
jobs = config.except(*self.class.nodes.keys)
global = config.slice(*self.class.nodes.keys)
super(global.merge(jobs: jobs))
end
##
# Temporary refactoring stub
#
def jobs
@config[:jobs]
end
def stages
stages_defined? ? stages_value : types_value
end
......
......@@ -22,7 +22,9 @@ describe Gitlab::Ci::Config::Node::Global do
variables: { VAR: 'value' },
after_script: ['make clean'],
stages: ['build', 'pages'],
cache: { key: 'k', untracked: true, paths: ['public/'] } }
cache: { key: 'k', untracked: true, paths: ['public/'] },
rspec: { script: 'rspec' },
spinach: { script: 'spinach' } }
end
describe '#process!' do
......@@ -120,6 +122,14 @@ describe Gitlab::Ci::Config::Node::Global do
.to eq(key: 'k', untracked: true, paths: ['public/'])
end
end
describe '#jobs' do
it 'returns jobs configuration' do
expect(global.jobs)
.to eq(rspec: { script: 'rspec' },
spinach: { script: 'spinach' })
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