Commit 56a01151 authored by Kamil Trzciński's avatar Kamil Trzciński

Allow to store null variables

parent 2e3dab38
...@@ -6,8 +6,8 @@ module Gitlab ...@@ -6,8 +6,8 @@ module Gitlab
class Collection class Collection
class Item class Item
def initialize(key:, value:, public: true, file: false) def initialize(key:, value:, public: true, file: false)
raise ArgumentError, "`#{key}` must be of type String, while it was: #{value.class}" unless raise ArgumentError, "`#{key}` must be of type String or nil value, while it was: #{value.class}" unless
value.is_a?(String) value.is_a?(String) || value.nil?
@variable = { @variable = {
key: key, value: value, public: public, file: file key: key, value: value, public: public, file: file
......
...@@ -36,7 +36,7 @@ describe Gitlab::Ci::Variables::Collection::Item do ...@@ -36,7 +36,7 @@ describe Gitlab::Ci::Variables::Collection::Item do
shared_examples 'raises error for invalid type' do shared_examples 'raises error for invalid type' do
it do it do
expect { described_class.new(key: variable_key, value: variable_value) } 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
end end
...@@ -46,7 +46,7 @@ describe Gitlab::Ci::Variables::Collection::Item do ...@@ -46,7 +46,7 @@ describe Gitlab::Ci::Variables::Collection::Item do
let(:variable_value) { nil } let(:variable_value) { nil }
let(:expected_value) { nil } let(:expected_value) { nil }
it_behaves_like 'raises error for invalid type' it_behaves_like 'creates variable'
end end
context "when it's an empty string" do context "when it's an empty string" 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