diff options
author | Mario de la Ossa <mdelaossa@gitlab.com> | 2018-03-06 21:16:55 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-03-06 21:16:55 +0000 |
commit | f9d61717cfa1956fd75a3c9bc4577172affd730e (patch) | |
tree | 960dea31740bb82de98b852a5c1f8f088d4d1ad4 /spec/lib | |
parent | 135ef031024ea95d3dc014c5f0ef46983372f2f3 (diff) | |
download | gitlab-ce-f9d61717cfa1956fd75a3c9bc4577172affd730e.tar.gz |
Gitlab::Utils - backport `.ensure_array_from_string` from EE
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/utils_spec.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb index bda239b7871..71a743495a2 100644 --- a/spec/lib/gitlab/utils_spec.rb +++ b/spec/lib/gitlab/utils_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Gitlab::Utils do - delegate :to_boolean, :boolean_to_yes_no, :slugify, :random_string, :which, to: :described_class + delegate :to_boolean, :boolean_to_yes_no, :slugify, :random_string, :which, :ensure_array_from_string, to: :described_class describe '.slugify' do { @@ -83,4 +83,18 @@ describe Gitlab::Utils do expect(which('sh', 'PATH' => '/bin')).to eq('/bin/sh') end end + + describe '.ensure_array_from_string' do + it 'returns the same array if given one' do + arr = ['a', 4, true, { test: 1 }] + + expect(ensure_array_from_string(arr)).to eq(arr) + end + + it 'turns comma-separated strings into arrays' do + str = 'seven, eight, 9, 10' + + expect(ensure_array_from_string(str)).to eq(%w[seven eight 9 10]) + end + end end |