Skip to content

Commit 4b19d5b

Browse files
committed
Remove deprecated ActionDispatch::Response#to_ary
1 parent 7676659 commit 4b19d5b

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `ActionDispatch::Response#to_ary`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `ActionDispatch::Request#deep_munge`.
26

37
*Rafael Mendonça França*

actionpack/lib/action_dispatch/http/response.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'active_support/core_ext/module/attribute_accessors'
22
require 'active_support/core_ext/string/filters'
3-
require 'active_support/deprecation'
43
require 'action_dispatch/http/filter_redirect'
54
require 'monitor'
65

@@ -284,20 +283,6 @@ def to_a
284283
end
285284
alias prepare! to_a
286285

287-
# Be super clear that a response object is not an Array. Defining this
288-
# would make implicit splatting work, but it also makes adding responses
289-
# as arrays work, and "flattening" responses, cascading to the rack body!
290-
# Not sensible behavior.
291-
def to_ary
292-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
293-
`ActionDispatch::Response#to_ary` no longer performs implicit conversion
294-
to an array. Please use `response.to_a` instead, or a splat like `status,
295-
headers, body = *response`.
296-
MSG
297-
298-
to_a
299-
end
300-
301286
# Returns the response cookies, converted to a Hash of (name => value) pairs
302287
#
303288
# assert_equal 'AuthorOfNewPage', r.cookies['author']

actionpack/test/dispatch/response_test.rb

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ def test_response_body_encoding
231231
assert_equal ['Not Found'], body.each.to_a
232232
end
233233

234-
test "[response].flatten does not recurse infinitely" do
234+
test "[response.to_a].flatten does not recurse infinitely" do
235235
Timeout.timeout(1) do # use a timeout to prevent it stalling indefinitely
236-
status, headers, body = assert_deprecated { [@response].flatten }
236+
status, headers, body = [@response.to_a].flatten
237237
assert_equal @response.status, status
238238
assert_equal @response.headers, headers
239239
assert_equal @response.body, body.each.to_a.join
@@ -251,20 +251,6 @@ def test_response_body_encoding
251251
status, headers, body = Rack::ContentLength.new(app).call(env)
252252
assert_equal '5', headers['Content-Length']
253253
end
254-
255-
test "implicit destructuring and Array conversion is deprecated" do
256-
response = ActionDispatch::Response.new(404, { 'Content-Type' => 'text/plain' }, ['Not Found'])
257-
258-
assert_deprecated do
259-
status, headers, body = response
260-
261-
assert_equal 404, status
262-
assert_equal({ 'Content-Type' => 'text/plain' }, headers)
263-
assert_equal ['Not Found'], body.each.to_a
264-
end
265-
266-
assert_deprecated { response.to_ary }
267-
end
268254
end
269255

270256
class ResponseIntegrationTest < ActionDispatch::IntegrationTest

0 commit comments

Comments
 (0)