diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-06 00:50:00 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-06 00:50:00 -0800 |
commit | 688e4f0fd1f715bf2d81523fa828bdae5f6743a1 (patch) | |
tree | 1176a476ced796af718c04382a45e3a219390a7b /actionpack/test | |
parent | e1a882a15b71435ec82a596978429b34d4c73ac5 (diff) | |
parent | 82a8698e564e5c27ac3516f0b44449a74b4389be (diff) | |
download | rails-688e4f0fd1f715bf2d81523fa828bdae5f6743a1.tar.gz rails-688e4f0fd1f715bf2d81523fa828bdae5f6743a1.tar.bz2 rails-688e4f0fd1f715bf2d81523fa828bdae5f6743a1.zip |
Merge pull request #5299 from sikachu/3-2-stable-fix-responder
Always passing a respond block from to responder
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 7c4fb59c15..f00ddb1799 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -1152,3 +1152,39 @@ class MimeControllerLayoutsTest < ActionController::TestCase assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body end end + +class FlashResponder < ActionController::Responder + def initialize(controller, resources, options={}) + super + end + + def to_html + controller.flash[:notice] = 'Success' + super + end +end + +class FlashResponderController < ActionController::Base + self.responder = FlashResponder + respond_to :html + + def index + respond_with Object.new do |format| + format.html { render :text => 'HTML' } + end + end +end + +class FlashResponderControllerTest < ActionController::TestCase + tests FlashResponderController + + def test_respond_with_block_executed + get :index + assert_equal 'HTML', @response.body + end + + def test_flash_responder_executed + get :index + assert_equal 'Success', flash[:notice] + end +end |