diff options
author | Dave Copeland <davetron5000@gmail.com> | 2015-05-29 07:34:19 -0500 |
---|---|---|
committer | Dave Copeland <davetron5000@gmail.com> | 2015-06-20 12:00:07 -0400 |
commit | 6fda6c3778b27ea9ca70645bb65956154c2da27b (patch) | |
tree | b66b520b57bf497a2b02ed7a08042a4f52ea07bd /actionpack/test/controller/mime | |
parent | 068ab23a33b245d8f481bb839549806280effe48 (diff) | |
download | rails-6fda6c3778b27ea9ca70645bb65956154c2da27b.tar.gz rails-6fda6c3778b27ea9ca70645bb65956154c2da27b.tar.bz2 rails-6fda6c3778b27ea9ca70645bb65956154c2da27b.zip |
Override default_render's behavior with a block
In 0de4a23 the behavior when there is a missing template was changed to
not raise an error, but instead head :no_content. This is a breaking
change and some gems rely on this happening.
To allow gems and other code to work around this, allow
`default_render` to take a block which, if provided, will
execute the contents of that block instead of doing the `head :no_content`.
Diffstat (limited to 'actionpack/test/controller/mime')
-rw-r--r-- | actionpack/test/controller/mime/respond_to_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb index 7aef8a50ce..8591bdb4d9 100644 --- a/actionpack/test/controller/mime/respond_to_test.rb +++ b/actionpack/test/controller/mime/respond_to_test.rb @@ -793,3 +793,24 @@ class RespondToControllerTest < ActionController::TestCase assert_equal "phone", @response.body end end + +class RespondToWithBlockOnDefaultRenderController < ActionController::Base + def show + default_render do + render text: 'default_render yielded' + end + end +end + +class RespondToWithBlockOnDefaultRenderControllerTest < ActionController::TestCase + def setup + super + @request.host = "www.example.com" + end + + def test_default_render_uses_block_when_no_template_exists + get :show + assert_equal "default_render yielded", @response.body + assert_equal "text/html", @response.content_type + end +end |