diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-23 03:06:01 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-23 03:06:01 +0000 |
commit | 8c7eab92cd0009f55cb999bbade43e0f969c137e (patch) | |
tree | 180cac6632448a211ddbe555191574c98e8dc385 /spec/lib/gitlab/utils_spec.rb | |
parent | dffeff5520e861dc6e7319b690c573186bbbd22e (diff) | |
download | gitlab-ce-8c7eab92cd0009f55cb999bbade43e0f969c137e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/utils_spec.rb')
-rw-r--r-- | spec/lib/gitlab/utils_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb index 890918d4a7c..a68434c8c66 100644 --- a/spec/lib/gitlab/utils_spec.rb +++ b/spec/lib/gitlab/utils_spec.rb @@ -252,4 +252,41 @@ describe Gitlab::Utils do expect(described_class.string_to_ip_object('1:0:0:0:0:0:0:0/124')).to eq(IPAddr.new('1:0:0:0:0:0:0:0/124')) end end + + describe '.allow_hash_values' do + it 'removes keys that do not pass the inclusion filters' do + symbols = %i[x y z] + ints = (0..100) + strings = %w[foo bar baz].to_set + + hash = { + a: :x, + b: 100, + c: 'foo', + d: :irrelevant, + aa: :w, + bb: 200, + cc: 'food', + dd: :totally_irrelevant + } + allowed = { + a: symbols, + b: ints, + c: strings, + aa: symbols, + bb: ints, + cc: strings + } + + described_class.allow_hash_values(hash, allowed) + + expect(hash).to eq({ + a: :x, + b: 100, + c: 'foo', + d: :irrelevant, + dd: :totally_irrelevant + }) + end + end end |