提交 920df0a4 编写于 作者: S Santiago Pastorino 提交者: Jeremy Kemper

Make ActionDispatch url_for use HWIA symbolize_keys

Signed-off-by: NJeremy Kemper <jeremy@bitsweat.net>
上级 2472f102
......@@ -128,7 +128,7 @@ def url_for(options = nil)
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
......
......@@ -258,13 +258,17 @@ def test_multiple_includes_maintain_distinct_options
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 @@ def extract_params(url)
end
end
end
end
\ No newline at end of file
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册