Permalink
Browse files

Don't create a deprecation proxy object if the variable was passed in…

… local_assigns [#1671 state:resolved]
  • Loading branch information...
1 parent df78de2 commit 0e52a609fd38856100ef5ab4ce8fe1207e417eca @pixeltrix pixeltrix committed Oct 25, 2010
Showing with 19 additions and 1 deletion.
  1. +7 −1 actionpack/lib/action_view/renderable_partial.rb
  2. +12 −0 actionpack/test/controller/render_test.rb
@@ -27,7 +27,7 @@ def render(view, local_assigns = {})
def render_partial(view, object = nil, local_assigns = {}, as = nil)
object ||= local_assigns[:object] || local_assigns[variable_name]
- if object.nil? && view.respond_to?(:controller)
+ if object.nil? && !local_assigns_key?(local_assigns) && view.respond_to?(:controller)
ivar = :"@#{variable_name}"
object =
if view.controller.instance_variable_defined?(ivar)
@@ -43,5 +43,11 @@ def render_partial(view, object = nil, local_assigns = {}, as = nil)
render_template(view, local_assigns)
end
+
+ private
+
+ def local_assigns_key?(local_assigns)
+ local_assigns.key?(:object) || local_assigns.key?(variable_name)
+ end
end
end
@@ -716,6 +716,11 @@ def partial_with_implicit_local_assignment
render :partial => "customer"
end
+ def partial_with_implicit_local_assignment_and_nil_local
+ @customer = Customer.new("Marcel")
+ render :partial => "customer", :locals => { :customer => nil }
+ end
+
def render_call_to_partial_with_layout
render :action => "calling_partial_with_layout"
end
@@ -1543,6 +1548,13 @@ def test_partial_with_implicit_local_assignment
end
end
+ def test_partial_with_implicit_local_assignment_and_nil_local
+ assert_not_deprecated do
+ get :partial_with_implicit_local_assignment_and_nil_local
+ assert_equal "Hello: Anonymous", @response.body
+ end
+ end
+
def test_render_missing_partial_template
assert_raise(ActionView::MissingTemplate) do
get :missing_partial

0 comments on commit 0e52a60

Please sign in to comment.