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:
parent
9476daa829
commit
275e839b8d
2 changed files with 11 additions and 1 deletions
|
@ -128,7 +128,7 @@ module ActionDispatch
|
||||||
when String
|
when String
|
||||||
options
|
options
|
||||||
when nil, Hash
|
when nil, Hash
|
||||||
_router.url_for(url_options.merge(options || {}))
|
_router.url_for(url_options.merge(options || {}).symbolize_keys)
|
||||||
else
|
else
|
||||||
polymorphic_url(options)
|
polymorphic_url(options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -257,6 +257,16 @@ module AbstractController
|
||||||
assert_equal second_class.default_url_options[:host], second_host
|
assert_equal second_class.default_url_options[:host], second_host
|
||||||
end
|
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
|
private
|
||||||
def extract_params(url)
|
def extract_params(url)
|
||||||
url.split('?', 2).last.split('&').sort
|
url.split('?', 2).last.split('&').sort
|
||||||
|
|
Loading…
Reference in a new issue