Allow to store null variables

This commit is contained in:
Kamil Trzciński 2018-11-22 12:12:53 +01:00
parent 2e3dab3829
commit 56a01151d5
2 changed files with 4 additions and 4 deletions

View File

@ -6,8 +6,8 @@ module Gitlab
class Collection
class Item
def initialize(key:, value:, public: true, file: false)
raise ArgumentError, "`#{key}` must be of type String, while it was: #{value.class}" unless
value.is_a?(String)
raise ArgumentError, "`#{key}` must be of type String or nil value, while it was: #{value.class}" unless
value.is_a?(String) || value.nil?
@variable = {
key: key, value: value, public: public, file: file

View File

@ -36,7 +36,7 @@ describe Gitlab::Ci::Variables::Collection::Item do
shared_examples 'raises error for invalid type' do
it do
expect { described_class.new(key: variable_key, value: variable_value) }
.to raise_error ArgumentError, /`#{variable_key}` must be of type String, while it was:/
.to raise_error ArgumentError, /`#{variable_key}` must be of type String or nil value, while it was:/
end
end
@ -46,7 +46,7 @@ describe Gitlab::Ci::Variables::Collection::Item do
let(:variable_value) { nil }
let(:expected_value) { nil }
it_behaves_like 'raises error for invalid type'
it_behaves_like 'creates variable'
end
context "when it's an empty string" do