From 06c9e176ca1b74e99bc258295bfbd8d2f2f33563 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 29 Jul 2012 17:55:39 -0700 Subject: raise exceptions on header set after response committed --- actionpack/test/dispatch/live_response_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/live_response_test.rb b/actionpack/test/dispatch/live_response_test.rb index 70dd7524aa..d17d516a0b 100644 --- a/actionpack/test/dispatch/live_response_test.rb +++ b/actionpack/test/dispatch/live_response_test.rb @@ -40,6 +40,25 @@ module ActionController @response.stream.write 'omg' assert_nil @response.headers['Content-Length'] end + + def test_headers_cannot_be_written_after_write + @response.stream.write 'omg' + + e = assert_raises(ActionDispatch::IllegalStateError) do + @response.headers['Content-Length'] = "zomg" + end + + assert_equal 'header already sent', e.message + end + + def test_headers_cannot_be_written_after_close + @response.stream.close + + e = assert_raises(ActionDispatch::IllegalStateError) do + @response.headers['Content-Length'] = "zomg" + end + assert_equal 'header already sent', e.message + end end end end -- cgit v1.2.3