aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorYoshiyuki Kinjo <yskkin@gmail.com>2018-09-21 13:49:59 +0900
committerYoshiyuki Kinjo <yskkin@gmail.com>2018-10-08 08:05:40 +0900
commit7f80be29a2655757985b8f70855940f4dc5445cf (patch)
tree0aca90c417c378b18c9cfb922576b84034a4c48a /actionpack/test
parent0b4cfa2ba3e978386240e0e56a409616cc32fd02 (diff)
downloadrails-7f80be29a2655757985b8f70855940f4dc5445cf.tar.gz
rails-7f80be29a2655757985b8f70855940f4dc5445cf.tar.bz2
rails-7f80be29a2655757985b8f70855940f4dc5445cf.zip
Deprecate ActionDispatch::Http::ParameterFilter in favor of ActiveSupport::ParameterFilter
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/dispatch/request_test.rb44
1 files changed, 3 insertions, 41 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index c7b68e5266..9d1246b3a4 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -1059,47 +1059,9 @@ class RequestParameters < BaseRequestTest
end
class RequestParameterFilter < BaseRequestTest
- test "process parameter filter" do
- test_hashes = [
- [{ "foo" => "bar" }, { "foo" => "bar" }, %w'food'],
- [{ "foo" => "bar" }, { "foo" => "[FILTERED]" }, %w'foo'],
- [{ "foo" => "bar", "bar" => "foo" }, { "foo" => "[FILTERED]", "bar" => "foo" }, %w'foo baz'],
- [{ "foo" => "bar", "baz" => "foo" }, { "foo" => "[FILTERED]", "baz" => "[FILTERED]" }, %w'foo baz'],
- [{ "bar" => { "foo" => "bar", "bar" => "foo" } }, { "bar" => { "foo" => "[FILTERED]", "bar" => "foo" } }, %w'fo'],
- [{ "foo" => { "foo" => "bar", "bar" => "foo" } }, { "foo" => "[FILTERED]" }, %w'f banana'],
- [{ "deep" => { "cc" => { "code" => "bar", "bar" => "foo" }, "ss" => { "code" => "bar" } } }, { "deep" => { "cc" => { "code" => "[FILTERED]", "bar" => "foo" }, "ss" => { "code" => "bar" } } }, %w'deep.cc.code'],
- [{ "baz" => [{ "foo" => "baz" }, "1"] }, { "baz" => [{ "foo" => "[FILTERED]" }, "1"] }, [/foo/]]]
-
- test_hashes.each do |before_filter, after_filter, filter_words|
- parameter_filter = ActionDispatch::Http::ParameterFilter.new(filter_words)
- assert_equal after_filter, parameter_filter.filter(before_filter)
-
- filter_words << "blah"
- filter_words << lambda { |key, value|
- value.reverse! if key =~ /bargain/
- }
- filter_words << lambda { |key, value, original_params|
- value.replace("world!") if original_params["barg"]["blah"] == "bar" && key == "hello"
- }
-
- parameter_filter = ActionDispatch::Http::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!" } } }
-
- assert_equal after_filter, parameter_filter.filter(before_filter)
- end
- end
-
- test "parameter filter should maintain hash with indifferent access" do
- test_hashes = [
- [{ "foo" => "bar" }.with_indifferent_access, ["blah"]],
- [{ "foo" => "bar" }.with_indifferent_access, []]
- ]
-
- test_hashes.each do |before_filter, filter_words|
- parameter_filter = ActionDispatch::Http::ParameterFilter.new(filter_words)
- assert_instance_of ActiveSupport::HashWithIndifferentAccess,
- parameter_filter.filter(before_filter)
+ test "parameter filter is deprecated" do
+ assert_deprecated do
+ ActionDispatch::Http::ParameterFilter.new(["blah"])
end
end