Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make rendering an empty partial collection behave like :nothing => true

#2080 [Sam Stephenson]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 01af965a3e68f719fe9cfdce36a82ad8901fe7a7 1 parent 49c67ea
@jamis jamis authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Make rendering an empty partial collection behave like :nothing => true #2080 [Sam Stephenson]
+
* Add option to specify the singular name used by pagination.
* Use string key to obtain action value. Allows indifferent hashes to be disabled.
View
2  actionpack/lib/action_view/partials.rb
@@ -67,7 +67,7 @@ def render_partial_collection(partial_name, collection, partial_spacer_template
collection_of_partials.push(render_partial(partial_name, element, local_assigns))
end
- return nil if collection_of_partials.empty?
+ return " " if collection_of_partials.empty?
if partial_spacer_template
spacer_path, spacer_name = partial_pieces(partial_spacer_template)
View
9 actionpack/test/controller/new_render_test.rb
@@ -98,6 +98,10 @@ def partial_collection_with_locals
render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" }
end
+ def empty_partial_collection
+ render :partial => "customer", :collection => []
+ end
+
def hello_in_a_string
@customers = [ Customer.new("david"), Customer.new("mary") ]
render :text => "How's there? #{render_to_string("test/list")}"
@@ -358,6 +362,11 @@ def test_partial_collection_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body
end
+ def test_empty_partial_collection
+ get :empty_partial_collection
+ assert_equal " ", @response.body
+ end
+
def test_render_text_with_assigns
get :render_text_with_assigns
assert_equal "world", assigns["hello"]
Please sign in to comment.
Something went wrong with that request. Please try again.