Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 06:06:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 06:06:01 +0300
commit8c7eab92cd0009f55cb999bbade43e0f969c137e (patch)
tree180cac6632448a211ddbe555191574c98e8dc385 /spec/lib/gitlab/utils_spec.rb
parentdffeff5520e861dc6e7319b690c573186bbbd22e (diff)
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.rb37
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