From 069bc273853c90194606b1725113d77ae39e2edd Mon Sep 17 00:00:00 2001 From: Dan Kang Date: Sat, 8 Feb 2014 17:40:08 -0800 Subject: 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. --- actionpack/test/dispatch/response_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 82d29867fe..959a3bc5cd 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -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 -- cgit v1.2.3