Namespace
- CLASS ActionController::LiveStreamTest::Exception
- CLASS ActionController::LiveStreamTest::TestController
Methods
- A
- C
- 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_set_response!,
- 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 247 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
test_abort_with_full_buffer()
Link
# File actionpack/test/controller/live_stream_test.rb, line 300 def test_abort_with_full_buffer @controller.latch = ActiveSupport::Concurrency::Latch.new @request.parameters[:format] = 'plain' @controller.request = @request @controller.response = @response got_error = ActiveSupport::Concurrency::Latch.new @response.stream.on_error do ActionController::Base.logger.warn 'Error while streaming' got_error.release end t = Thread.new(@response) { |resp| resp.await_commit _, _, body = resp.to_a body.each do |part| @controller.latch.await body.close break end } capture_log_output do |output| @controller.process :overfill_buffer_and_die t.join got_error.await assert_match 'Error while streaming', output.rewind && output.read end end
test_async_stream()
Link
# File actionpack/test/controller/live_stream_test.rb, line 278 def test_async_stream @controller.latch = ActiveSupport::Concurrency::Latch.new parts = ['hello', 'world'] @controller.request = @request @controller.response = @response t = Thread.new(@response) { |resp| resp.await_commit resp.stream.each do |part| assert_equal parts.shift, part ol = @controller.latch @controller.latch = ActiveSupport::Concurrency::Latch.new ol.release end } @controller.process :blocking_stream 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 406 def test_exception_callback_when_committed capture_log_output do |output| get :exception_with_callback, format: 'text/event-stream' 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 378 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 393 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 427 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 331 def test_ignore_client_disconnect @controller.latch = ActiveSupport::Concurrency::Latch.new @controller.request = @request @controller.response = @response t = Thread.new(@response) { |resp| resp.await_commit _, _, body = resp.to_a body.each do |part| body.close break end } capture_log_output do |output| @controller.process :ignore_client_disconnect t.join Timeout.timeout(3) do @controller.latch.await end assert_match 'Work complete', output.rewind && output.read end end
test_live_stream_default_header()
Link
test_render_text()
Link
test_set_response!()
Link
test_stale_with_etag()
Link
test_stale_without_etag()
Link
test_thread_locals_get_copied()
Link
test_write_to_stream()
Link