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

Make sure render :collection doesnt set nil local when :as is absent

This commit is contained in:
Pratik Naik 2008-07-02 17:19:41 +01:00
parent 2b43620e3c
commit 267d3964eb
3 changed files with 8 additions and 1 deletions

View file

@ -23,7 +23,8 @@ module ActionView #:nodoc:
end
def render_member(object)
@locals[:object] = @locals[@variable_name] = @locals[as] = object
@locals[:object] = @locals[@variable_name] = object
@locals[as] = object if as
template = render_template
@locals[@counter_name] += 1

View file

@ -0,0 +1 @@
<%= local_assigns.keys.map(&:to_s).sort.join(",") -%>

View file

@ -59,6 +59,11 @@ class ViewRenderTest < Test::Unit::TestCase
assert_equal "david david davidmary mary mary",
@view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer)
end
def test_render_partial_collection_without_as
assert_equal "local_inspector,local_inspector_counter,object",
@view.render(:partial => "test/local_inspector", :collection => [ Customer.new("mary") ])
end
# TODO: The reason for this test is unclear, improve documentation
def test_render_partial_and_fallback_to_layout