Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
bb0f4a12
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,发现更多精彩内容 >>
提交
bb0f4a12
编写于
9月 30, 2012
作者:
Y
Yves Senn
提交者:
Yves Senn
10月 01, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prefix TemplateAssertions ivars (#7459)
上级
d0ad97b9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
23 deletion
+29
-23
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+6
-0
actionpack/lib/action_controller/test_case.rb
actionpack/lib/action_controller/test_case.rb
+20
-20
actionpack/lib/action_view/test_case.rb
actionpack/lib/action_view/test_case.rb
+3
-3
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
bb0f4a12
## Rails 4.0.0 (unreleased) ##
*
Rename internal variables on ActionController::TemplateAssertions to prevent
naming collisions. @partials, @templates and @layouts are now prefixed with an underscore.
Fix #7459
*Yves Senn*
*
`resource`
and
`resources`
don't modify the passed options hash
Fix #7777
...
...
actionpack/lib/action_controller/test_case.rb
浏览文件 @
bb0f4a12
...
...
@@ -12,16 +12,16 @@ module TemplateAssertions
end
def
setup_subscriptions
@partials
=
Hash
.
new
(
0
)
@templates
=
Hash
.
new
(
0
)
@layouts
=
Hash
.
new
(
0
)
@
_
partials
=
Hash
.
new
(
0
)
@
_
templates
=
Hash
.
new
(
0
)
@
_
layouts
=
Hash
.
new
(
0
)
ActiveSupport
::
Notifications
.
subscribe
(
"render_template.action_view"
)
do
|
name
,
start
,
finish
,
id
,
payload
|
path
=
payload
[
:layout
]
if
path
@layouts
[
path
]
+=
1
@
_
layouts
[
path
]
+=
1
if
path
=~
/^layouts\/(.*)/
@layouts
[
$1
]
+=
1
@
_
layouts
[
$1
]
+=
1
end
end
end
...
...
@@ -32,11 +32,11 @@ def setup_subscriptions
partial
=
path
=~
/^.*\/_[^\/]*$/
if
partial
@partials
[
path
]
+=
1
@partials
[
path
.
split
(
"/"
).
last
]
+=
1
@
_
partials
[
path
]
+=
1
@
_
partials
[
path
.
split
(
"/"
).
last
]
+=
1
end
@templates
[
path
]
+=
1
@
_
templates
[
path
]
+=
1
end
end
...
...
@@ -46,9 +46,9 @@ def teardown_subscriptions
end
def
process
(
*
args
)
@partials
=
Hash
.
new
(
0
)
@templates
=
Hash
.
new
(
0
)
@layouts
=
Hash
.
new
(
0
)
@
_
partials
=
Hash
.
new
(
0
)
@
_
templates
=
Hash
.
new
(
0
)
@
_
layouts
=
Hash
.
new
(
0
)
super
end
...
...
@@ -88,7 +88,7 @@ def assert_template(options = {}, message = nil)
case
options
when
NilClass
,
Regexp
,
String
,
Symbol
options
=
options
.
to_s
if
Symbol
===
options
rendered
=
@templates
rendered
=
@
_
templates
msg
=
message
||
sprintf
(
"expecting <%s> but rendering with <%s>"
,
options
.
inspect
,
rendered
.
keys
)
matches_template
=
...
...
@@ -109,15 +109,15 @@ def assert_template(options = {}, message = nil)
if
options
.
key?
(
:layout
)
expected_layout
=
options
[
:layout
]
msg
=
message
||
sprintf
(
"expecting layout <%s> but action rendered <%s>"
,
expected_layout
,
@layouts
.
keys
)
expected_layout
,
@
_
layouts
.
keys
)
case
expected_layout
when
String
,
Symbol
assert_includes
@layouts
.
keys
,
expected_layout
.
to_s
,
msg
assert_includes
@
_
layouts
.
keys
,
expected_layout
.
to_s
,
msg
when
Regexp
assert
(
@layouts
.
keys
.
any?
{
|
l
|
l
=~
expected_layout
},
msg
)
assert
(
@
_
layouts
.
keys
.
any?
{
|
l
|
l
=~
expected_layout
},
msg
)
when
nil
,
false
assert
(
@layouts
.
empty?
,
msg
)
assert
(
@
_
layouts
.
empty?
,
msg
)
end
end
...
...
@@ -128,17 +128,17 @@ def assert_template(options = {}, message = nil)
assert_equal
(
v
,
actual_locals
[
k
])
end
elsif
expected_count
=
options
[
:count
]
actual_count
=
@partials
[
expected_partial
]
actual_count
=
@
_
partials
[
expected_partial
]
msg
=
message
||
sprintf
(
"expecting %s to be rendered %s time(s) but rendered %s time(s)"
,
expected_partial
,
expected_count
,
actual_count
)
assert
(
actual_count
==
expected_count
.
to_i
,
msg
)
else
msg
=
message
||
sprintf
(
"expecting partial <%s> but action rendered <%s>"
,
options
[
:partial
],
@partials
.
keys
)
assert_includes
@partials
,
expected_partial
,
msg
options
[
:partial
],
@
_
partials
.
keys
)
assert_includes
@
_
partials
,
expected_partial
,
msg
end
elsif
options
.
key?
(
:partial
)
assert
@partials
.
empty?
,
assert
@
_
partials
.
empty?
,
"Expected no partials to be rendered"
end
else
...
...
actionpack/lib/action_view/test_case.rb
浏览文件 @
bb0f4a12
...
...
@@ -196,17 +196,17 @@ def view
:@_result
,
:@_routes
,
:@controller
,
:@layouts
,
:@
_
layouts
,
:@locals
,
:@method_name
,
:@output_buffer
,
:@partials
,
:@
_
partials
,
:@passed
,
:@rendered
,
:@request
,
:@routes
,
:@tagged_logger
,
:@templates
,
:@
_
templates
,
:@options
,
:@test_passed
,
:@view
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录