aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorPatrick Toomey <ptoomey3@biasedcoin.com>2019-05-31 07:36:37 -0600
committerPatrick Toomey <ptoomey3@biasedcoin.com>2019-05-31 07:36:37 -0600
commit06992d50522c5dd2e7fa26bc257cc416b7f47cc8 (patch)
tree1f199f5182e95fed45183011439ec1f540c09e0b /activesupport/test
parentf0445213d8f23c982d1c080a750b33d4855d46e4 (diff)
downloadrails-06992d50522c5dd2e7fa26bc257cc416b7f47cc8.tar.gz
rails-06992d50522c5dd2e7fa26bc257cc416b7f47cc8.tar.bz2
rails-06992d50522c5dd2e7fa26bc257cc416b7f47cc8.zip
Add failing test for array values and procs
Based on the way parameters are currently processed, a parameter value of type Hash is recursively processed. For a value of type Array however, the current behavior is to simply return the original array, with no filtering. It is not clear what the expected behavior should be. But, doing nothing seems incorrect, since it bypasses custom Proc based parameter filtering all together for arrays of values. This change introduces a failing test in preparation to add logic that proposes one possible option for the expected behavior with Array values.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/parameter_filter_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/test/parameter_filter_test.rb b/activesupport/test/parameter_filter_test.rb
index d2dc71061d..889380fea3 100644
--- a/activesupport/test/parameter_filter_test.rb
+++ b/activesupport/test/parameter_filter_test.rb
@@ -28,10 +28,18 @@ class ParameterFilterTest < ActiveSupport::TestCase
value.replace("world!") if original_params["barg"]["blah"] == "bar" && key == "hello"
}
+
+ filter_words << lambda { |key, value|
+ value.upcase! if key == "array_elements"
+ }
+
parameter_filter = ActiveSupport::ParameterFilter.new(filter_words)
before_filter["barg"] = { :bargain => "gain", "blah" => "bar", "bar" => { "bargain" => { "blah" => "foo", "hello" => "world" } } }
after_filter["barg"] = { :bargain => "niag", "blah" => "[FILTERED]", "bar" => { "bargain" => { "blah" => "[FILTERED]", "hello" => "world!" } } }
+ before_filter["array_elements"] = %w(element1 element2)
+ after_filter["array_elements"] = %w(ELEMENT1 ELEMENT2)
+
assert_equal after_filter, parameter_filter.filter(before_filter)
end
end