From 06992d50522c5dd2e7fa26bc257cc416b7f47cc8 Mon Sep 17 00:00:00 2001 From: Patrick Toomey Date: Fri, 31 May 2019 07:36:37 -0600 Subject: 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. --- activesupport/test/parameter_filter_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/test') 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 -- cgit v1.2.3