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

Make ActionDispatch url_for use HWIA symbolize_keys

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
Santiago Pastorino 2010-04-22 12:33:54 -03:00 committed by Jeremy Kemper
parent 2472f1026a
commit 920df0a475
2 changed files with 8 additions and 4 deletions

View file

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

View file

@ -258,13 +258,17 @@ module AbstractController
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))
assert_equal("/c/a", W.new.url_for('controller' => 'c', 'action' => 'a', '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)))
W.default_url_options[:controller] = 'd'
W.default_url_options[:only_path] = false
assert_equal("/c", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'only_path' => true)))
W.default_url_options[:action] = 'b'
assert_equal("/c/a", W.new.url_for(HashWithIndifferentAccess.new('controller' => 'c', 'action' => 'a', 'only_path' => true)))
end
private
@ -273,4 +277,4 @@ module AbstractController
end
end
end
end
end