2017-07-24 16:20:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:54:50 -04:00
|
|
|
require "abstract_unit"
|
2012-07-29 18:51:21 -04:00
|
|
|
|
|
|
|
module ActionController
|
|
|
|
class StreamingResponseTest < ActionController::TestCase
|
|
|
|
class TestController < ActionController::Base
|
|
|
|
def self.controller_path
|
2016-08-06 12:54:50 -04:00
|
|
|
"test"
|
2012-07-29 18:51:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def basic_stream
|
|
|
|
%w{ hello world }.each do |word|
|
|
|
|
response.stream.write word
|
|
|
|
response.stream.write "\n"
|
|
|
|
end
|
|
|
|
response.stream.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests TestController
|
|
|
|
|
|
|
|
def test_write_to_stream
|
|
|
|
get :basic_stream
|
|
|
|
assert_equal "hello\nworld\n", @response.body
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|