From 71d19f15171e59b5dfddd66f3fa3a234c3f7911d Mon Sep 17 00:00:00 2001 From: Lauro Caetano Date: Thu, 28 Nov 2013 23:01:57 -0200 Subject: [PATCH] Fix stream closing when sending file with `ActionController::Live` included. Fixes #12381 --- actionpack/CHANGELOG.md | 6 ++++++ actionpack/lib/action_controller/metal/live.rb | 2 +- actionpack/test/controller/send_file_test.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index f52a07eaee9..e65b73aa66c 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,9 @@ +* Fix stream closing when sending file with `ActionController::Live` included. + + Fixes #12381 + + *Alessandro Diaferia* + * Better error message for typos in assert_response argument. When the response type argument to `assert_response` is not a known diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb index 0dd788645bd..09ea4919c26 100644 --- a/actionpack/lib/action_controller/metal/live.rb +++ b/actionpack/lib/action_controller/metal/live.rb @@ -234,7 +234,7 @@ module ActionController def response_body=(body) super - response.stream.close if response + response.close if response end def set_response!(request) diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 8ecc1c7d734..0326bf45624 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -25,6 +25,10 @@ class SendFileController < ActionController::Base end end +class SendFileWithActionControllerLive < SendFileController + include ActionController::Live +end + class SendFileTest < ActionController::TestCase tests SendFileController include TestFileUtils @@ -196,4 +200,14 @@ class SendFileTest < ActionController::TestCase assert_equal 200, @response.status end end + + tests SendFileWithActionControllerLive + + def test_send_file_with_action_controller_live + @controller = SendFileWithActionControllerLive.new + @controller.options = { :content_type => "application/x-ruby" } + + response = process('file') + assert_equal 200, response.status + end end