Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d77b306b
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,体验更适合开发者的 AI 搜索 >>
提交
d77b306b
编写于
5月 15, 2011
作者:
P
Prem Sichanugrist
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make ParamsWrapper calling newly introduced `Model.attribute_names` instead of `.column_names`
上级
5ca67eca
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
12 addition
and
14 deletion
+12
-14
actionpack/CHANGELOG
actionpack/CHANGELOG
+1
-1
actionpack/lib/action_controller/metal/params_wrapper.rb
actionpack/lib/action_controller/metal/params_wrapper.rb
+3
-3
actionpack/test/controller/params_wrapper_test.rb
actionpack/test/controller/params_wrapper_test.rb
+8
-10
未找到文件。
actionpack/CHANGELOG
浏览文件 @
d77b306b
actionpack/lib/action_controller/metal/params_wrapper.rb
浏览文件 @
d77b306b
...
@@ -163,8 +163,8 @@ def _set_wrapper_defaults(options, model=nil)
...
@@ -163,8 +163,8 @@ def _set_wrapper_defaults(options, model=nil)
unless
options
[
:only
]
||
options
[
:except
]
unless
options
[
:only
]
||
options
[
:except
]
model
||=
_default_wrap_model
model
||=
_default_wrap_model
if
!
(
model
.
respond_to?
(
:abstract_class?
)
&&
model
.
abstract_class?
)
&&
model
.
respond_to?
(
:column_names
)
if
model
.
respond_to?
(
:attribute_names
)
&&
model
.
attribute_names
.
present?
options
[
:only
]
=
model
.
column
_names
options
[
:only
]
=
model
.
attribute
_names
end
end
end
end
...
...
actionpack/test/controller/params_wrapper_test.rb
浏览文件 @
d77b306b
...
@@ -133,9 +133,8 @@ def test_nested_params
...
@@ -133,9 +133,8 @@ def test_nested_params
end
end
def
test_derived_wrapped_keys_from_matching_model
def
test_derived_wrapped_keys_from_matching_model
User
.
expects
(
:respond_to?
).
with
(
:abstract_class?
).
returns
(
false
)
User
.
expects
(
:respond_to?
).
with
(
:attribute_names
).
returns
(
true
)
User
.
expects
(
:respond_to?
).
with
(
:column_names
).
returns
(
true
)
User
.
expects
(
:attribute_names
).
twice
.
returns
([
"username"
])
User
.
expects
(
:column_names
).
returns
([
"username"
])
with_default_wrapper_options
do
with_default_wrapper_options
do
@request
.
env
[
'CONTENT_TYPE'
]
=
'application/json'
@request
.
env
[
'CONTENT_TYPE'
]
=
'application/json'
...
@@ -146,9 +145,8 @@ def test_derived_wrapped_keys_from_matching_model
...
@@ -146,9 +145,8 @@ def test_derived_wrapped_keys_from_matching_model
def
test_derived_wrapped_keys_from_specified_model
def
test_derived_wrapped_keys_from_specified_model
with_default_wrapper_options
do
with_default_wrapper_options
do
Person
.
expects
(
:respond_to?
).
with
(
:abstract_class?
).
returns
(
false
)
Person
.
expects
(
:respond_to?
).
with
(
:attribute_names
).
returns
(
true
)
Person
.
expects
(
:respond_to?
).
with
(
:column_names
).
returns
(
true
)
Person
.
expects
(
:attribute_names
).
twice
.
returns
([
"username"
])
Person
.
expects
(
:column_names
).
returns
([
"username"
])
UsersController
.
wrap_parameters
Person
UsersController
.
wrap_parameters
Person
...
@@ -159,8 +157,8 @@ def test_derived_wrapped_keys_from_specified_model
...
@@ -159,8 +157,8 @@ def test_derived_wrapped_keys_from_specified_model
end
end
def
test_not_wrapping_abstract_model
def
test_not_wrapping_abstract_model
User
.
expects
(
:respond_to?
).
with
(
:a
bstract_class?
).
returns
(
true
)
User
.
expects
(
:respond_to?
).
with
(
:a
ttribute_names
).
returns
(
true
)
User
.
expects
(
:a
bstract_class?
).
returns
(
true
)
User
.
expects
(
:a
ttribute_names
).
returns
([]
)
with_default_wrapper_options
do
with_default_wrapper_options
do
@request
.
env
[
'CONTENT_TYPE'
]
=
'application/json'
@request
.
env
[
'CONTENT_TYPE'
]
=
'application/json'
...
@@ -198,13 +196,13 @@ def parse
...
@@ -198,13 +196,13 @@ def parse
end
end
class
SampleOne
class
SampleOne
def
self
.
column
_names
def
self
.
attribute
_names
[
"username"
]
[
"username"
]
end
end
end
end
class
SampleTwo
class
SampleTwo
def
self
.
column
_names
def
self
.
attribute
_names
[
"title"
]
[
"title"
]
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录