Test for Pruner

This commit is contained in:
Senad Uka
2018-08-13 18:54:12 +02:00
parent 5684e58826
commit 973f1e1093
15 changed files with 2888 additions and 53 deletions

View File

@@ -1,5 +1,6 @@
module Pruning
module HTTP
# Whitelists the URL query parameters
class Query < Struct.new(:name, :indicator_ids)
def initialize(params = {})
symbolised = params.map { |k, v| { k.to_sym => v } }.reduce({}, :merge)
@@ -7,9 +8,9 @@ module Pruning
value = symbolised.fetch(member, nil)
next if value.nil?
case member
when :indicator_ids then value.map(&->(indicator_id) { indicator_id.to_i } ) # break on purpose if indicator_ids is not an array
when :name then value.to_s.gsub(/[^A-Za-z]/,'')
else value
when :indicator_ids then value.map(&->(indicator_id) { indicator_id.to_i }) # break on purpose if indicator_ids is not an array
when :name then value.to_s.gsub(/[^A-Za-z]/, '')
else value
end
end
super(*values)