mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Prevent [response].flatten from recursing infinitely.
Returning `self` from within the array returned by `to_ary` caused this. Instead, we can just substitute another object. It provides the `each` behavior required by the rack spec.
This commit is contained in:
parent
cbd10e27d1
commit
069bc27385
2 changed files with 10 additions and 1 deletions
|
@ -313,7 +313,7 @@ module ActionDispatch # :nodoc:
|
|||
header.delete CONTENT_TYPE
|
||||
[status, header, []]
|
||||
else
|
||||
[status, header, self]
|
||||
[status, header, Rack::BodyProxy.new(self){}]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -226,6 +226,15 @@ class ResponseTest < ActiveSupport::TestCase
|
|||
assert_equal({ 'Content-Type' => 'text/plain' }, headers)
|
||||
assert_equal ['Not Found'], body.each.to_a
|
||||
end
|
||||
|
||||
test "[response].flatten does not recurse infinitely" do
|
||||
Timeout.timeout(1) do # use a timeout to prevent it stalling indefinitely
|
||||
status, headers, body = [@response].flatten
|
||||
assert_equal @response.status, status
|
||||
assert_equal @response.headers, headers
|
||||
assert_equal @response.body, body.each.to_a.join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ResponseIntegrationTest < ActionDispatch::IntegrationTest
|
||||
|
|
Loading…
Reference in a new issue