Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 275e839b8dfa3cf2bdedf1b31302dec20ac96a46 1 parent 9476daa
@dark-panda dark-panda authored josevalim committed
View
2  actionpack/lib/action_dispatch/routing/url_for.rb
@@ -128,7 +128,7 @@ def url_for(options = nil)
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
10 actionpack/test/controller/url_for_test.rb
@@ -257,6 +257,16 @@ def test_multiple_includes_maintain_distinct_options
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
Please sign in to comment.
Something went wrong with that request. Please try again.