aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authormisfo <tedwardo2@gmail.com>2011-02-08 12:08:35 +0800
committerDavid Heinemeier Hansson <david@loudthinking.com>2011-04-28 04:07:57 +0800
commit9f6cafd5fd43b551f30b28d276713791c5098b3c (patch)
tree2ff4d3805d4ff234201aebd645281c5e69db6142 /actionpack/test/controller
parent1cd5a084c1bb92d8acf618368d2450a084b69345 (diff)
downloadrails-9f6cafd5fd43b551f30b28d276713791c5098b3c.tar.gz
rails-9f6cafd5fd43b551f30b28d276713791c5098b3c.tar.bz2
rails-9f6cafd5fd43b551f30b28d276713791c5098b3c.zip
prevent errors when passing a frozen string as a param to ActionController::TestCase#process
since ActionDispatch::Http::Parameters#encode_params will force encoding on all params strings (when using an encoding aware Ruby), dup all strings passed into process. This prevents modification of params passed in and, more importantly, doesn't barf when a frozen string is passed thanks and high fives to kinsteronline
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/test_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index edda0d0a30..5896222a0a 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -493,6 +493,18 @@ XML
)
end
+ def test_params_passing_with_frozen_values
+ assert_nothing_raised do
+ get :test_params, :frozen => 'icy'.freeze, :frozens => ['icy'.freeze].freeze
+ end
+ parsed_params = eval(@response.body)
+ assert_equal(
+ {'controller' => 'test_test/test', 'action' => 'test_params',
+ 'frozen' => 'icy', 'frozens' => ['icy']},
+ parsed_params
+ )
+ end
+
def test_id_converted_to_string
get :test_params, :id => 20, :foo => Object.new
assert_kind_of String, @request.path_parameters['id']