diff options
author | Toon Claes <toon@gitlab.com> | 2017-03-20 22:05:53 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-03-20 22:53:29 +0100 |
commit | 71306f14f69b9798a21905cfa8160c4990ca5d5d (patch) | |
tree | 007e5b27082767b6c75eab003a610c28597d7efd /spec/lib/gitlab/visibility_level_spec.rb | |
parent | dd3d62b626f97800e9e72834455def675a879528 (diff) | |
download | gitlab-ce-71306f14f69b9798a21905cfa8160c4990ca5d5d.tar.gz |
Make level_value accept string integers
When a VisibilityLevel is an integer formatted as a string, convert it
to an integer, instead of looking it up in the hash map.
When the value is not recognized, default to PRIVATE.
Diffstat (limited to 'spec/lib/gitlab/visibility_level_spec.rb')
-rw-r--r-- | spec/lib/gitlab/visibility_level_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb new file mode 100644 index 00000000000..3255c6f1ef7 --- /dev/null +++ b/spec/lib/gitlab/visibility_level_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Gitlab::VisibilityLevel, lib: true do + describe '.level_value' do + it 'converts "public" to integer value' do + expect(described_class.level_value('public')).to eq(Gitlab::VisibilityLevel::PUBLIC) + end + + it 'converts string integer to integer value' do + expect(described_class.level_value('20')).to eq(20) + end + + it 'defaults to PRIVATE when string value is not valid' do + expect(described_class.level_value('invalid')).to eq(Gitlab::VisibilityLevel::PRIVATE) + end + + it 'defaults to PRIVATE when integer value is not valid' do + expect(described_class.level_value(100)).to eq(Gitlab::VisibilityLevel::PRIVATE) + end + end +end |