Skip to content
Browse files
Remove deprecated ActionDispatch::Response#to_ary
  • Loading branch information
rafaelfranca committed Jan 4, 2015
1 parent 7676659 commit 4b19d5b7bcdf4f11bd1e2e9ed2149a958e338c01
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
@@ -1,3 +1,7 @@
* Remove deprecated `ActionDispatch::Response#to_ary`.

*Rafael Mendonça França*

* Remove deprecated `ActionDispatch::Request#deep_munge`.

*Rafael Mendonça França*
@@ -1,6 +1,5 @@
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/string/filters'
require 'active_support/deprecation'
require 'action_dispatch/http/filter_redirect'
require 'monitor'

@@ -284,20 +283,6 @@ def to_a
alias prepare! to_a

# Be super clear that a response object is not an Array. Defining this
# would make implicit splatting work, but it also makes adding responses
# as arrays work, and "flattening" responses, cascading to the rack body!
# Not sensible behavior.
def to_ary
`ActionDispatch::Response#to_ary` no longer performs implicit conversion
to an array. Please use `response.to_a` instead, or a splat like `status,
headers, body = *response`.


# Returns the response cookies, converted to a Hash of (name => value) pairs
# assert_equal 'AuthorOfNewPage', r.cookies['author']
@@ -231,9 +231,9 @@ def test_response_body_encoding
assert_equal ['Not Found'], body.each.to_a

test "[response].flatten does not recurse infinitely" do
test "[response.to_a].flatten does not recurse infinitely" do
Timeout.timeout(1) do # use a timeout to prevent it stalling indefinitely
status, headers, body = assert_deprecated { [@response].flatten }
status, headers, body = [@response.to_a].flatten
assert_equal @response.status, status
assert_equal @response.headers, headers
assert_equal @response.body, body.each.to_a.join
@@ -251,20 +251,6 @@ def test_response_body_encoding
status, headers, body =
assert_equal '5', headers['Content-Length']

test "implicit destructuring and Array conversion is deprecated" do
response =, { '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

assert_deprecated { response.to_ary }

class ResponseIntegrationTest < ActionDispatch::IntegrationTest

0 comments on commit 4b19d5b

Please sign in to comment.