2017-07-24 16:20:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:54:50 -04:00
|
|
|
require "abstract_unit"
|
2015-04-15 14:30:27 -04:00
|
|
|
|
|
|
|
module TestApiFileUtils
|
2017-05-15 10:17:28 -04:00
|
|
|
def file_path() __FILE__ end
|
2016-08-06 12:54:50 -04:00
|
|
|
def file_data() @data ||= File.open(file_path, "rb") { |f| f.read } end
|
2015-04-15 14:30:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class DataStreamingApiController < ActionController::API
|
|
|
|
include TestApiFileUtils
|
|
|
|
|
|
|
|
def one; end
|
|
|
|
def two
|
|
|
|
send_data(file_data, {})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class DataStreamingApiTest < ActionController::TestCase
|
|
|
|
include TestApiFileUtils
|
|
|
|
tests DataStreamingApiController
|
|
|
|
|
|
|
|
def test_data
|
2016-08-06 12:54:50 -04:00
|
|
|
response = process("two")
|
2015-04-15 14:30:27 -04:00
|
|
|
assert_kind_of String, response.body
|
|
|
|
assert_equal file_data, response.body
|
|
|
|
end
|
|
|
|
end
|