aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-21 16:50:11 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-21 16:52:49 +0100
commitfc4f237864541f5012f9b8cc8e0ec81960377e55 (patch)
treeaf89be8dd26fe96044d4b9114f1cea1a4e6910cc /actionpack/test/controller
parent04063393f9392b83cf5ccd0a16f217cc7261e15c (diff)
downloadrails-fc4f237864541f5012f9b8cc8e0ec81960377e55.tar.gz
rails-fc4f237864541f5012f9b8cc8e0ec81960377e55.tar.bz2
rails-fc4f237864541f5012f9b8cc8e0ec81960377e55.zip
Make filter parameters based on request, so they can be modified for anything in the middleware stack.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/base_test.rb21
-rw-r--r--actionpack/test/controller/subscriber_test.rb5
2 files changed, 20 insertions, 6 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 1510a6a7e0..4fcfbacf4e 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -2,6 +2,9 @@ require 'abstract_unit'
require 'logger'
require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
+module Rails
+end
+
# Provide some controller to run the tests on.
module Submodule
class ContainedEmptyController < ActionController::Base
@@ -63,7 +66,7 @@ class DefaultUrlOptionsController < ActionController::Base
end
end
-class ControllerClassTests < Test::Unit::TestCase
+class ControllerClassTests < ActiveSupport::TestCase
def test_controller_path
assert_equal 'empty', EmptyController.controller_path
assert_equal EmptyController.controller_path, EmptyController.new.controller_path
@@ -74,7 +77,21 @@ class ControllerClassTests < Test::Unit::TestCase
def test_controller_name
assert_equal 'empty', EmptyController.controller_name
assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
- end
+ end
+
+ def test_filter_parameter_logging
+ parameters = []
+ config = mock(:config => mock(:filter_parameters => parameters))
+ Rails.expects(:application).returns(config)
+
+ assert_deprecated do
+ Class.new(ActionController::Base) do
+ filter_parameter_logging :password
+ end
+ end
+
+ assert_equal [:password], parameters
+ end
end
class ControllerInstanceTests < Test::Unit::TestCase
diff --git a/actionpack/test/controller/subscriber_test.rb b/actionpack/test/controller/subscriber_test.rb
index bd0c83413c..152a0d0c04 100644
--- a/actionpack/test/controller/subscriber_test.rb
+++ b/actionpack/test/controller/subscriber_test.rb
@@ -97,8 +97,7 @@ class ACSubscriberTest < ActionController::TestCase
end
def test_process_action_with_filter_parameters
- ActionDispatch::Request.class_eval "alias :safe_process_parameter_filter :process_parameter_filter"
- ActionDispatch::Request.filter_parameters(:lifo, :amount)
+ @request.env["action_dispatch.parameter_filter"] = [:lifo, :amount]
get :show, :lifo => 'Pratik', :amount => '420', :step => '1'
wait
@@ -107,8 +106,6 @@ class ACSubscriberTest < ActionController::TestCase
assert_match /"amount"=>"\[FILTERED\]"/, params
assert_match /"lifo"=>"\[FILTERED\]"/, params
assert_match /"step"=>"1"/, params
- ensure
- ActionDispatch::Request.class_eval "alias :process_parameter_filter :safe_process_parameter_filter"
end
def test_redirect_to