summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-10-28 18:56:13 -0200
committerFelipe Artur <felipefac@gmail.com>2016-11-01 11:03:56 -0200
commitf4e31b820e0cebd0f4bd0fe5a5d6a7a3c903a969 (patch)
tree989a8987858d3d8891a31b941a4a54d052deaaea /spec/lib
parent957308af84ca8312ea362c7272a4008dac808086 (diff)
downloadgitlab-ce-f4e31b820e0cebd0f4bd0fe5a5d6a7a3c903a969.tar.gz
Fix project features default values
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/utils_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb
new file mode 100644
index 00000000000..d5d87310874
--- /dev/null
+++ b/spec/lib/gitlab/utils_spec.rb
@@ -0,0 +1,35 @@
+describe Gitlab::Utils, lib: true do
+ def to_boolean(value)
+ described_class.to_boolean(value)
+ end
+
+ describe '.to_boolean' do
+ it 'accepts booleans' do
+ expect(to_boolean(true)).to be(true)
+ expect(to_boolean(false)).to be(false)
+ end
+
+ it 'converts a valid string to a boolean' do
+ expect(to_boolean(true)).to be(true)
+ expect(to_boolean('true')).to be(true)
+ expect(to_boolean('YeS')).to be(true)
+ expect(to_boolean('t')).to be(true)
+ expect(to_boolean('1')).to be(true)
+ expect(to_boolean('ON')).to be(true)
+
+ expect(to_boolean('FaLse')).to be(false)
+ expect(to_boolean('F')).to be(false)
+ expect(to_boolean('NO')).to be(false)
+ expect(to_boolean('n')).to be(false)
+ expect(to_boolean('0')).to be(false)
+ expect(to_boolean('oFF')).to be(false)
+ end
+
+ it 'converts an invalid string to nil' do
+ expect(to_boolean('fals')).to be_nil
+ expect(to_boolean('yeah')).to be_nil
+ expect(to_boolean('')).to be_nil
+ expect(to_boolean(nil)).to be_nil
+ end
+ end
+end