mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Don't modify params in place - fixes #2624
This commit is contained in:
committed by
Santiago Pastorino
parent
5978faefd1
commit
283f5971c6
@@ -398,9 +398,7 @@ module ActionController
|
||||
def paramify_values(hash_or_array_or_value)
|
||||
case hash_or_array_or_value
|
||||
when Hash
|
||||
hash_or_array_or_value.each do |key, value|
|
||||
hash_or_array_or_value[key] = paramify_values(value)
|
||||
end
|
||||
Hash[hash_or_array_or_value.map{|key, value| [key, paramify_values(value)] }]
|
||||
when Array
|
||||
hash_or_array_or_value.map {|i| paramify_values(i)}
|
||||
when Rack::Test::UploadedFile
|
||||
@@ -413,7 +411,7 @@ module ActionController
|
||||
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
|
||||
# Ensure that numbers and symbols passed as params are converted to
|
||||
# proper params, as is the case when engaging rack.
|
||||
paramify_values(parameters)
|
||||
parameters = paramify_values(parameters)
|
||||
|
||||
# Sanity check for required instance variables so we can give an
|
||||
# understandable error message.
|
||||
@@ -447,7 +445,7 @@ module ActionController
|
||||
@controller.params.merge!(parameters)
|
||||
build_request_uri(action, parameters)
|
||||
@controller.class.class_eval { include Testing }
|
||||
@controller.recycle!
|
||||
@controller.recycle!
|
||||
@controller.process_with_new_base_test(@request, @response)
|
||||
@assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
|
||||
@request.session.delete('flash') if @request.session['flash'].blank?
|
||||
|
||||
@@ -519,6 +519,12 @@ XML
|
||||
)
|
||||
end
|
||||
|
||||
def test_params_passing_doesnt_modify_in_place
|
||||
page = {:name => "Page name", :month => 4, :year => 2004, :day => 6}
|
||||
get :test_params, :page => page
|
||||
assert_equal 2004, page[:year]
|
||||
end
|
||||
|
||||
def test_id_converted_to_string
|
||||
get :test_params, :id => 20, :foo => Object.new
|
||||
assert_kind_of String, @request.path_parameters['id']
|
||||
|
||||
Reference in New Issue
Block a user