From 2a78d6f561e98684a4988cdc616c6096cd4302d1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 5 Sep 2014 13:33:20 -0700 Subject: Deprecate implicit AD::Response splatting and Array conversion --- actionpack/test/dispatch/response_test.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'actionpack/test/dispatch/response_test.rb') diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 187b9a2420..af188191e3 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -220,9 +220,9 @@ class ResponseTest < ActiveSupport::TestCase assert @response.respond_to?(:method_missing, true) end - test "can be destructured into status, headers and an enumerable body" do + test "can be explicitly destructured into status, headers and an enumerable body" do response = ActionDispatch::Response.new(404, { 'Content-Type' => 'text/plain' }, ['Not Found']) - status, headers, body = response + status, headers, body = *response assert_equal 404, status assert_equal({ 'Content-Type' => 'text/plain' }, headers) @@ -231,12 +231,26 @@ class ResponseTest < ActiveSupport::TestCase 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 + status, headers, body = assert_deprecated { [@response].flatten } assert_equal @response.status, status assert_equal @response.headers, headers assert_equal @response.body, body.each.to_a.join end end + + test "implicit destructuring and Array conversion is deprecated" do + response = ActionDispatch::Response.new(404, { 'Content-Type' => 'text/plain' }, ['Not Found']) + + assert_deprecated do + status, headers, body = response + + assert_equal 404, status + assert_equal({ 'Content-Type' => 'text/plain' }, headers) + assert_equal ['Not Found'], body.each.to_a + end + + assert_deprecated { response.to_ary } + end end class ResponseIntegrationTest < ActionDispatch::IntegrationTest -- cgit v1.2.3