提交 b44bfa4c 编写于 作者: A Aaron Patterson

always pass options to the _url method

上级 7f97eac6
......@@ -135,9 +135,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
named_route = build_named_route_call(record_or_hash_or_array, record, inflection, options)
url_options = options.except(:action, :routing_type)
unless url_options.empty?
args << url_options
end
args << url_options
args.collect! { |a| convert_to_model(a) }
......
......@@ -37,10 +37,20 @@ def test_homepage_url
def test_link_to_person
with_test_route_set do
person = mock(:name => "David")
person.class.extend ActiveModel::Naming
expects(:mocha_mock_path).with(person).returns("/people/1")
person = Struct.new(:name) {
extend ActiveModel::Naming
def self.name; 'Mocha::Mock'; end
}.new "David"
the_model = nil
extend Module.new {
define_method(:mocha_mock_path) { |model, *args|
the_model = model
"/people/1"
}
}
assert_equal '<a href="/people/1">David</a>', link_to_person(person)
assert_equal person, the_model
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册