Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4b19d5b7
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4b19d5b7
编写于
1月 02, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove deprecated `ActionDispatch::Response#to_ary`
上级
76766596
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
31 deletion
+6
-31
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+4
-0
actionpack/lib/action_dispatch/http/response.rb
actionpack/lib/action_dispatch/http/response.rb
+0
-15
actionpack/test/dispatch/response_test.rb
actionpack/test/dispatch/response_test.rb
+2
-16
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
4b19d5b7
*
Remove deprecated
`ActionDispatch::Response#to_ary`
.
*Rafael Mendonça França*
*
Remove deprecated
`ActionDispatch::Request#deep_munge`
.
*
Remove deprecated
`ActionDispatch::Request#deep_munge`
.
*Rafael Mendonça França*
*Rafael Mendonça França*
...
...
actionpack/lib/action_dispatch/http/response.rb
浏览文件 @
4b19d5b7
require
'active_support/core_ext/module/attribute_accessors'
require
'active_support/core_ext/module/attribute_accessors'
require
'active_support/core_ext/string/filters'
require
'active_support/core_ext/string/filters'
require
'active_support/deprecation'
require
'action_dispatch/http/filter_redirect'
require
'action_dispatch/http/filter_redirect'
require
'monitor'
require
'monitor'
...
@@ -284,20 +283,6 @@ def to_a
...
@@ -284,20 +283,6 @@ def to_a
end
end
alias
prepare!
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
ActiveSupport
::
Deprecation
.
warn
(
<<-
MSG
.
squish
)
`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`.
MSG
to_a
end
# Returns the response cookies, converted to a Hash of (name => value) pairs
# Returns the response cookies, converted to a Hash of (name => value) pairs
#
#
# assert_equal 'AuthorOfNewPage', r.cookies['author']
# assert_equal 'AuthorOfNewPage', r.cookies['author']
...
...
actionpack/test/dispatch/response_test.rb
浏览文件 @
4b19d5b7
...
@@ -231,9 +231,9 @@ def test_response_body_encoding
...
@@ -231,9 +231,9 @@ def test_response_body_encoding
assert_equal
[
'Not Found'
],
body
.
each
.
to_a
assert_equal
[
'Not Found'
],
body
.
each
.
to_a
end
end
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
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
.
status
,
status
assert_equal
@response
.
headers
,
headers
assert_equal
@response
.
headers
,
headers
assert_equal
@response
.
body
,
body
.
each
.
to_a
.
join
assert_equal
@response
.
body
,
body
.
each
.
to_a
.
join
...
@@ -251,20 +251,6 @@ def test_response_body_encoding
...
@@ -251,20 +251,6 @@ def test_response_body_encoding
status
,
headers
,
body
=
Rack
::
ContentLength
.
new
(
app
).
call
(
env
)
status
,
headers
,
body
=
Rack
::
ContentLength
.
new
(
app
).
call
(
env
)
assert_equal
'5'
,
headers
[
'Content-Length'
]
assert_equal
'5'
,
headers
[
'Content-Length'
]
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
end
class
ResponseIntegrationTest
<
ActionDispatch
::
IntegrationTest
class
ResponseIntegrationTest
<
ActionDispatch
::
IntegrationTest
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录