diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-11-22 12:12:53 +0100 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-11-23 15:20:07 +0100 |
commit | 56a01151d5c8e85d50069f88c22017ed4c8c06eb (patch) | |
tree | dfd7d43259ed4672d45538c870fbd9eadb50739d | |
parent | 2e3dab38295b7c36ab100f20c654fdfaf9b00885 (diff) | |
download | gitlab-ce-56a01151d5c8e85d50069f88c22017ed4c8c06eb.tar.gz |
Allow to store null variablesfix-null-variables
-rw-r--r-- | lib/gitlab/ci/variables/collection/item.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/variables/collection/item_spec.rb | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb index cf8958e34c2..e3e4e62cc02 100644 --- a/lib/gitlab/ci/variables/collection/item.rb +++ b/lib/gitlab/ci/variables/collection/item.rb @@ -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 diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb index e1e0582cd11..8bf44acb228 100644 --- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb @@ -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 |