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:
parent
2b43620e3c
commit
267d3964eb
3 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
|
1
actionpack/test/fixtures/test/_local_inspector.html.erb
vendored
Normal file
1
actionpack/test/fixtures/test/_local_inspector.html.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<%= local_assigns.keys.map(&:to_s).sort.join(",") -%>
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue