mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't modify params in place - fixes #2624
This commit is contained in:
parent
7079701e5b
commit
14cf4b2e35
2 changed files with 9 additions and 5 deletions
|
@ -401,9 +401,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
|
||||
|
@ -416,7 +414,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.
|
||||
|
@ -450,7 +448,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?
|
||||
|
|
|
@ -515,6 +515,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']
|
||||
|
|
Loading…
Reference in a new issue