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

Added tests to render helper that expect render partial: @foo to

automatically call @foo.to_partial_path

Calling `render @foo` allows local variables but not options to be
passed to the partial renderer. The correct way to render an object AND
pass options to the partial renderer is to pass the object in the
`:partial` parameter. However, there were previously no tests for this
behaviour (in `render_helper_test.rb` at least).
This commit is contained in:
Iain Beeston 2014-02-12 17:40:52 +00:00
parent f34e0c4a20
commit 5b793a8add
2 changed files with 11 additions and 0 deletions

View file

@ -0,0 +1 @@
<greeting><%= greeting %></greeting><name><%= customer.name %></name>

View file

@ -304,6 +304,16 @@ module RenderTestCases
assert_equal "Hola: david", @controller_view.render('customer_greeting', :greeting => 'Hola', :customer_greeting => Customer.new("david"))
end
def test_render_partial_with_object_uses_render_partial_path
assert_equal "Hello: lifo",
@controller_view.render(:partial => Customer.new("lifo"), :locals => {:greeting => "Hello"})
end
def test_render_partial_with_object_and_format_uses_render_partial_path
assert_equal "<greeting>Hello</greeting><name>lifo</name>",
@controller_view.render(:partial => Customer.new("lifo"), :formats => :xml, :locals => {:greeting => "Hello"})
end
def test_render_partial_using_object
assert_equal "Hello: lifo",
@controller_view.render(Customer.new("lifo"), :greeting => "Hello")