summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2018-04-12 09:58:49 +0200
committerJames Lopez <james@jameslopez.es>2018-04-12 09:58:49 +0200
commit0015fc7d205cd86d0347385372791e470ff3ed3a (patch)
treeaf2ab0a4d5f602710968fe01736ec60cacee09e4
parent24a654db62631ecf08687530e6ca93002340d36a (diff)
parentc393a44f2fa5e161c8055bc589f10d4ee2e1d8a0 (diff)
downloadgitlab-ce-0015fc7d205cd86d0347385372791e470ff3ed3a.tar.gz
Merge remote-tracking branch 'origin/10-7-stable' into 10-7-stable-prepare-rc5
-rw-r--r--VERSION2
-rw-r--r--lib/gitlab/ci/variables/collection/item.rb7
-rw-r--r--spec/lib/gitlab/ci/variables/collection/item_spec.rb35
3 files changed, 33 insertions, 11 deletions
diff --git a/VERSION b/VERSION
index 6dab54c311b..05fd90cdbd6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-10.7.0-rc3
+10.7.0-rc4
diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb
index 23ed71db8b0..d00e5b07f95 100644
--- a/lib/gitlab/ci/variables/collection/item.rb
+++ b/lib/gitlab/ci/variables/collection/item.rb
@@ -3,12 +3,9 @@ module Gitlab
module Variables
class Collection
class Item
- def initialize(**options)
+ def initialize(key:, value:, public: true, file: false)
@variable = {
- key: options.fetch(:key),
- value: options.fetch(:value),
- public: options.fetch(:public, true),
- file: options.fetch(:files, false)
+ key: key, value: value, public: public, file: file
}
end
diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb
index bf9208f1ff4..e79f0a7f257 100644
--- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb
+++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb
@@ -5,6 +5,18 @@ describe Gitlab::Ci::Variables::Collection::Item do
{ key: 'VAR', value: 'something', public: true }
end
+ describe '.new' do
+ it 'raises error if unknown key i specified' do
+ expect { described_class.new(key: 'VAR', value: 'abc', files: true) }
+ .to raise_error ArgumentError, 'unknown keyword: files'
+ end
+
+ it 'raises error when required keywords are not specified' do
+ expect { described_class.new(key: 'VAR') }
+ .to raise_error ArgumentError, 'missing keyword: value'
+ end
+ end
+
describe '.fabricate' do
it 'supports using a hash' do
resource = described_class.fabricate(variable)
@@ -47,12 +59,25 @@ describe Gitlab::Ci::Variables::Collection::Item do
end
describe '#to_runner_variable' do
- it 'returns a runner-compatible hash representation' do
- runner_variable = described_class
- .new(**variable)
- .to_runner_variable
+ context 'when variable is not a file-related' do
+ it 'returns a runner-compatible hash representation' do
+ runner_variable = described_class
+ .new(**variable)
+ .to_runner_variable
+
+ expect(runner_variable).to eq variable
+ end
+ end
+
+ context 'when variable is file-related' do
+ it 'appends file description component' do
+ runner_variable = described_class
+ .new(key: 'VAR', value: 'value', file: true)
+ .to_runner_variable
- expect(runner_variable).to eq variable
+ expect(runner_variable)
+ .to eq(key: 'VAR', value: 'value', public: true, file: true)
+ end
end
end
end