Namespace
- CLASS ActionController::LiveStreamTest::Exception
- CLASS ActionController::LiveStreamTest::TestController
Methods
- A
- C
- S
- T
-
- test_abort_with_full_buffer,
- test_async_stream,
- test_bad_request_in_controller_before_streaming,
- test_exception_callback_when_committed,
- test_exception_handling_html,
- test_exception_handling_plain_text,
- test_exception_in_controller_before_streaming,
- test_exceptions_raised_handling_exceptions_and_committed,
- test_ignore_client_disconnect,
- test_live_stream_default_header,
- test_render_text,
- test_set_cookie,
- test_stale_with_etag,
- test_stale_without_etag,
- test_thread_locals_get_copied,
- test_write_to_stream
Instance Public methods
assert_stream_closed()
Link
capture_log_output()
Link
# File actionpack/test/controller/live_stream_test.rb, line 253 def capture_log_output output = StringIO.new old_logger, ActionController::Base.logger = ActionController::Base.logger, ActiveSupport::Logger.new(output) begin yield output ensure ActionController::Base.logger = old_logger end end
setup()
Link
test_abort_with_full_buffer()
Link
# File actionpack/test/controller/live_stream_test.rb, line 305 def test_abort_with_full_buffer @controller.latch = Concurrent::CountDownLatch.new @controller.error_latch = Concurrent::CountDownLatch.new capture_log_output do |output| get :overfill_buffer_and_die, :format => 'plain' t = Thread.new(response) { |resp| resp.await_commit _, _, body = resp.to_a body.each do @controller.latch.wait body.close break end } t.join @controller.error_latch.wait assert_match 'Error while streaming', output.rewind && output.read end end
test_async_stream()
Link
# File actionpack/test/controller/live_stream_test.rb, line 284 def test_async_stream rubinius_skip "https://github.com/rubinius/rubinius/issues/2934" @controller.latch = Concurrent::CountDownLatch.new parts = ['hello', 'world'] get :blocking_stream t = Thread.new(response) { |resp| resp.await_commit resp.stream.each do |part| assert_equal parts.shift, part ol = @controller.latch @controller.latch = Concurrent::CountDownLatch.new ol.count_down end } assert t.join(3), 'timeout expired before the thread terminated' end
test_bad_request_in_controller_before_streaming()
Link
test_exception_callback_when_committed()
Link
# File actionpack/test/controller/live_stream_test.rb, line 398 def test_exception_callback_when_committed current_threads = Thread.list capture_log_output do |output| get :exception_with_callback, format: 'text/event-stream' # Wait on the execution of all threads (Thread.list - current_threads).each(&:join) assert_equal %Q(data: "500 Internal Server Error"\n\n), response.body assert_match 'An exception occurred...', output.rewind && output.read assert_stream_closed end end
test_exception_handling_html()
Link
# File actionpack/test/controller/live_stream_test.rb, line 370 def test_exception_handling_html assert_raises(ActionView::MissingTemplate) do get :exception_in_view end capture_log_output do |output| get :exception_in_view_after_commit assert_match %r((window\.location = "/500\.html"</script></html>)$), response.body assert_match 'Missing template test/doesntexist', output.rewind && output.read assert_stream_closed end assert response.body assert_stream_closed end
test_exception_handling_plain_text()
Link
# File actionpack/test/controller/live_stream_test.rb, line 385 def test_exception_handling_plain_text assert_raises(ActionView::MissingTemplate) do get :exception_in_view, format: :json end capture_log_output do |output| get :exception_in_view_after_commit, format: :json assert_equal '', response.body assert_match 'Missing template test/doesntexist', output.rewind && output.read assert_stream_closed end end
test_exception_in_controller_before_streaming()
Link
test_exceptions_raised_handling_exceptions_and_committed()
Link
# File actionpack/test/controller/live_stream_test.rb, line 425 def test_exceptions_raised_handling_exceptions_and_committed capture_log_output do |output| get :exception_in_exception_callback, format: 'text/event-stream' assert_equal '', response.body assert_match 'We need to go deeper', output.rewind && output.read assert_stream_closed end end
test_ignore_client_disconnect()
Link
# File actionpack/test/controller/live_stream_test.rb, line 328 def test_ignore_client_disconnect @controller.latch = Concurrent::CountDownLatch.new capture_log_output do |output| get :ignore_client_disconnect t = Thread.new(response) { |resp| resp.await_commit _, _, body = resp.to_a body.each do body.close break end } t.join Timeout.timeout(3) do @controller.latch.wait end assert_match 'Work complete', output.rewind && output.read end end
test_live_stream_default_header()
Link
test_render_text()
Link
test_stale_with_etag()
Link
test_stale_without_etag()
Link
test_thread_locals_get_copied()
Link