Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
038574a5
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,发现更多精彩内容 >>
提交
038574a5
编写于
1月 16, 2013
作者:
C
Carlos Antonio da Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecate direct calls to AC::RecordIdentifier.dom_id and dom_class
Also add some generic tests to ensure they're properly deprecated.
上级
f5aa4d9a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
9 deletion
+58
-9
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+7
-4
actionpack/lib/action_controller/record_identifier.rb
actionpack/lib/action_controller/record_identifier.rb
+17
-5
actionpack/test/controller/record_identifier_test.rb
actionpack/test/controller/record_identifier_test.rb
+34
-0
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
038574a5
...
...
@@ -492,10 +492,13 @@
*Richard Schneeman*
*
Deprecate availbility of
`ActionView::RecordIdentifier`
in controllers by default.
It's view specific and can be easily included in controller manually if someone
really needs it. RecordIdentifier will be removed from
`ActionController::Base`
in Rails 4.1.
*Piotr Sarnacki*
*
Deprecate availability of
`ActionView::RecordIdentifier`
in controllers by default.
It's view specific and can be easily included in controllers manually if someone
really needs it. Also deprecate calling
`ActionController::RecordIdentifier.dom_id`
and
`dom_class`
directly, in favor of
`ActionView::RecordIdentifier.dom_id`
and
`dom_class`
.
`RecordIdentifier`
will be removed from
`ActionController::Base`
in Rails 4.1.
*Piotr Sarnacki*
*
Fix
`ActionView::RecordIdentifier`
to work as a singleton.
*Piotr Sarnacki*
...
...
actionpack/lib/action_controller/record_identifier.rb
浏览文件 @
038574a5
...
...
@@ -2,17 +2,29 @@
module
ActionController
module
RecordIdentifier
MESSAGE
=
'method will no longer be included by default in controllers since Rails 4.1. '
+
'If you would like to use it in controllers, please include '
+
'ActionView::RecordIdentifier module.'
MODULE_MESSAGE
=
'Calling ActionController::RecordIdentifier.%s is deprecated and '
\
'will be removed in Rails 4.1, please call using ActionView::RecordIdentifier instead.'
INSTANCE_MESSAGE
=
'%s method will no longer be included by default in controllers '
\
'since Rails 4.1. If you would like to use it in controllers, please include '
\
'ActionView::RecordIdentifier module.'
def
dom_id
(
record
,
prefix
=
nil
)
ActiveSupport
::
Deprecation
.
warn
(
'dom_id '
+
MESSAGE
)
ActiveSupport
::
Deprecation
.
warn
(
INSTANCE_MESSAGE
%
'dom_id'
)
ActionView
::
RecordIdentifier
.
dom_id
(
record
,
prefix
)
end
def
dom_class
(
record
,
prefix
=
nil
)
ActiveSupport
::
Deprecation
.
warn
(
'dom_class '
+
MESSAGE
)
ActiveSupport
::
Deprecation
.
warn
(
INSTANCE_MESSAGE
%
'dom_class'
)
ActionView
::
RecordIdentifier
.
dom_class
(
record
,
prefix
)
end
def
self
.
dom_id
(
record
,
prefix
=
nil
)
ActiveSupport
::
Deprecation
.
warn
(
MODULE_MESSAGE
%
'dom_id'
)
ActionView
::
RecordIdentifier
.
dom_id
(
record
,
prefix
)
end
def
self
.
dom_class
(
record
,
prefix
=
nil
)
ActiveSupport
::
Deprecation
.
warn
(
MODULE_MESSAGE
%
'dom_class'
)
ActionView
::
RecordIdentifier
.
dom_class
(
record
,
prefix
)
end
end
...
...
actionpack/test/controller/record_identifier_test.rb
0 → 100644
浏览文件 @
038574a5
require
'abstract_unit'
require
'controller/fake_models'
class
ControllerRecordIdentifierTest
<
ActiveSupport
::
TestCase
include
ActionController
::
RecordIdentifier
def
setup
@record
=
Comment
.
new
end
def
test_dom_id_deprecation
assert_deprecated
/dom_id method will no longer be included by default in controllers/
do
dom_id
(
@record
)
end
end
def
test_dom_class_deprecation
assert_deprecated
/dom_class method will no longer be included by default in controllers/
do
dom_class
(
@record
)
end
end
def
test_dom_id_from_module_deprecation
assert_deprecated
/Calling ActionController::RecordIdentifier.dom_id is deprecated/
do
ActionController
::
RecordIdentifier
.
dom_id
(
@record
)
end
end
def
test_dom_class_from_module_deprecation
assert_deprecated
/Calling ActionController::RecordIdentifier.dom_class is deprecated/
do
ActionController
::
RecordIdentifier
.
dom_class
(
@record
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录