aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorKevin Casey <kacasey@berkeley.edu>2014-02-15 13:05:00 -0800
committerKevin Casey <kacasey@berkeley.edu>2014-02-15 13:05:00 -0800
commit8508346dd06399aecd413b95da92b2d1b52f7d3c (patch)
tree686234a719e00be0c4a5ba72cca4df7ce8c8ceaf /actionpack/test
parent4914adc2b0f0c6338f0763e364db02dcf7d49255 (diff)
downloadrails-8508346dd06399aecd413b95da92b2d1b52f7d3c.tar.gz
rails-8508346dd06399aecd413b95da92b2d1b52f7d3c.tar.bz2
rails-8508346dd06399aecd413b95da92b2d1b52f7d3c.zip
Correct prestreaming controller response status.
if the controller action has not yet streamed any data, actions should process as normal, and errors should trigger the appropriate behavior (500, or in the case of ActionController::BadRequest, a 400 Bad Request)
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/live_stream_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/controller/live_stream_test.rb b/actionpack/test/controller/live_stream_test.rb
index 0a431270b5..fb6a750089 100644
--- a/actionpack/test/controller/live_stream_test.rb
+++ b/actionpack/test/controller/live_stream_test.rb
@@ -156,6 +156,14 @@ module ActionController
raise 'An exception occurred...'
end
+ def exception_in_controller
+ raise 'Exception in controller'
+ end
+
+ def bad_request_error
+ raise ActionController::BadRequest
+ end
+
def exception_in_exception_callback
response.headers['Content-Type'] = 'text/event-stream'
response.stream.on_error do
@@ -275,6 +283,16 @@ module ActionController
end
end
+ def test_exception_in_controller_before_streaming
+ response = get :exception_in_controller, format: 'text/event-stream'
+ assert_equal 500, response.status
+ end
+
+ def test_bad_request_in_controller_before_streaming
+ response = get :bad_request_error, format: 'text/event-stream'
+ assert_equal 400, response.status
+ end
+
def test_exceptions_raised_handling_exceptions
capture_log_output do |output|
get :exception_in_exception_callback, format: 'text/event-stream'