aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-07-02 17:19:41 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-07-02 17:19:41 +0100
commit267d3964ebd7bbc8879d69ff5a323527179c497d (patch)
treeb6e88cece3c135bc2e21e8a19d9c2945633741ef /actionpack
parent2b43620e3c1352028f19550fcde4632d65cbd191 (diff)
downloadrails-267d3964ebd7bbc8879d69ff5a323527179c497d.tar.gz
rails-267d3964ebd7bbc8879d69ff5a323527179c497d.tar.bz2
rails-267d3964ebd7bbc8879d69ff5a323527179c497d.zip
Make sure render :collection doesnt set nil local when :as is absent
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/partial_template.rb3
-rw-r--r--actionpack/test/fixtures/test/_local_inspector.html.erb1
-rw-r--r--actionpack/test/template/render_test.rb5
3 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/partial_template.rb b/actionpack/lib/action_view/partial_template.rb
index 3513244ecb..a2129952c0 100644
--- a/actionpack/lib/action_view/partial_template.rb
+++ b/actionpack/lib/action_view/partial_template.rb
@@ -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
diff --git a/actionpack/test/fixtures/test/_local_inspector.html.erb b/actionpack/test/fixtures/test/_local_inspector.html.erb
new file mode 100644
index 0000000000..c5a6e3e5bc
--- /dev/null
+++ b/actionpack/test/fixtures/test/_local_inspector.html.erb
@@ -0,0 +1 @@
+<%= local_assigns.keys.map(&:to_s).sort.join(",") -%> \ No newline at end of file
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 64244e50f7..5163c35189 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -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