aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/partials.rb2
-rw-r--r--actionpack/test/controller/new_render_test.rb9
3 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 9ff0ca0cb2..82f72df2bf 100644
--- a/actionpack/CHANGELOG
+++ b/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.
diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb
index 06dead1b23..e1dcd4ee9d 100644
--- a/actionpack/lib/action_view/partials.rb
+++ b/actionpack/lib/action_view/partials.rb
@@ -67,7 +67,7 @@ module ActionView
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)
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index a29a6b9cd2..7cb3643db5 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -98,6 +98,10 @@ class NewRenderTestController < ActionController::Base
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 @@ class NewRenderTest < Test::Unit::TestCase
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"]