Commit 981c2488 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not raise when adding undefined variables resource

parent eb2966fa
...@@ -17,6 +17,8 @@ module Gitlab ...@@ -17,6 +17,8 @@ module Gitlab
end end
def concat(resources) def concat(resources)
return self if resources.nil?
tap { resources.each { |variable| self.append(variable) } } tap { resources.each { |variable| self.append(variable) } }
end end
......
...@@ -66,6 +66,14 @@ describe Gitlab::Ci::Variables::Collection do ...@@ -66,6 +66,14 @@ describe Gitlab::Ci::Variables::Collection do
expect(collection).to include(key: 'VAR_3', value: '3', public: true) expect(collection).to include(key: 'VAR_3', value: '3', public: true)
end end
it 'does not concatenate resource if it undefined' do
collection = described_class.new([{ key: 'VAR_1', value: '1' }])
collection.concat(nil)
expect(collection).to be_one
end
it 'returns self' do it 'returns self' do
expect(subject.concat([key: 'VAR', value: 'test'])) expect(subject.concat([key: 'VAR', value: 'test']))
.to eq subject .to eq subject
......
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