Skip to content
Browse files

Support render :text => nil. Closes #6684.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8577 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 523658c commit ca4c7ab362d0110bfade496ca66b30bafdb7f25e @jeremy jeremy committed
Showing with 23 additions and 2 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +2 −2 actionpack/lib/action_controller/base.rb
  3. +19 −0 actionpack/test/controller/render_test.rb
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Support render :text => nil. #6684 [tjennings, PotatoSalad, Cheah Chu Yeow]
+
* assert_response failures include the exception message. #10688 [Seth Rasmussen]
* All fragment cache keys are now by default prefixed with the "views/" namespace [DHH]
View
4 actionpack/lib/action_controller/base.rb
@@ -850,8 +850,8 @@ def render(options = nil, &block) #:doc:
response.headers["Location"] = url_for(location)
end
- if text = options[:text]
- render_for_text(text, options[:status])
+ if options.has_key?(:text)
+ render_for_text(options[:text], options[:status])
else
if file = options[:file]
View
19 actionpack/test/controller/render_test.rb
@@ -57,6 +57,14 @@ def render_custom_code
render :text => "hello world", :status => 404
end
+ def render_text_with_nil
+ render :text => nil
+ end
+
+ def render_text_with_false
+ render :text => false
+ end
+
def render_nothing_with_appendix
render :text => "appended"
end
@@ -263,6 +271,17 @@ def test_render_custom_code
assert_equal 'hello world', @response.body
end
+ def test_render_text_with_nil
+ get :render_text_with_nil
+ assert_response 200
+ assert_equal '', @response.body
+ end
+
+ def test_render_text_with_false
+ get :render_text_with_false
+ assert_equal 'false', @response.body
+ end
+
def test_render_nothing_with_appendix
get :render_nothing_with_appendix
assert_response 200

0 comments on commit ca4c7ab

Please sign in to comment.
Something went wrong with that request. Please try again.