1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure that url_for uses symbolized keys in the controller. [#4391]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
J Smith 2010-04-21 21:37:51 -04:00 committed by José Valim
parent 9476daa829
commit 275e839b8d
2 changed files with 11 additions and 1 deletions

View file

@ -128,7 +128,7 @@ module ActionDispatch
when String
options
when nil, Hash
_router.url_for(url_options.merge(options || {}))
_router.url_for(url_options.merge(options || {}).symbolize_keys)
else
polymorphic_url(options)
end

View file

@ -257,6 +257,16 @@ module AbstractController
assert_equal second_class.default_url_options[:host], second_host
end
def test_with_stringified_keys
assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', 'only_path' => true))
assert_equal("/c", W.new.url_for('controller' => 'c', 'only_path' => true))
end
def test_with_hash_with_indifferent_access
assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true)))
assert_equal("/c", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'only_path' => true)))
end
private
def extract_params(url)
url.split('?', 2).last.split('&').sort