1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add support for Rack::ContentLength middelware

This commit is contained in:
Javan Makhmali 2014-09-03 11:16:37 -04:00
parent da2f61947d
commit 66f8997671
2 changed files with 18 additions and 0 deletions

View file

@ -380,6 +380,10 @@ module ActionDispatch # :nodoc:
def to_path
@response.stream.to_path
end
def to_ary
nil
end
end
def rack_response(status, header)

View file

@ -1,4 +1,6 @@
require 'abstract_unit'
require 'timeout'
require 'rack/content_length'
class ResponseTest < ActiveSupport::TestCase
def setup
@ -238,6 +240,18 @@ class ResponseTest < ActiveSupport::TestCase
end
end
test "compatibility with Rack::ContentLength" do
@response.body = 'Hello'
app = lambda { |env| @response.to_a }
env = Rack::MockRequest.env_for("/")
status, headers, body = app.call(env)
assert_nil headers['Content-Length']
status, headers, body = Rack::ContentLength.new(app).call(env)
assert_equal '5', headers['Content-Length']
end
test "implicit destructuring and Array conversion is deprecated" do
response = ActionDispatch::Response.new(404, { 'Content-Type' => 'text/plain' }, ['Not Found'])