aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-09-01 21:43:38 +0000
committerJamis Buck <jamis@37signals.com>2005-09-01 21:43:38 +0000
commit01af965a3e68f719fe9cfdce36a82ad8901fe7a7 (patch)
tree61677831a35ffded12a7c133ad31b4b7a98e5aff
parent49c67ea1b7411ea8c73fcba45fe15e76f8697282 (diff)
downloadrails-01af965a3e68f719fe9cfdce36a82ad8901fe7a7.tar.gz
rails-01af965a3e68f719fe9cfdce36a82ad8901fe7a7.tar.bz2
rails-01af965a3e68f719fe9cfdce36a82ad8901fe7a7.zip
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
-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"]