Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
1ee4eebb
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,发现更多精彩内容 >>
提交
1ee4eebb
编写于
6月 15, 2016
作者:
J
Javan Makhmali
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix finding templates for digesting for */* requests that render a non-default (html) template
上级
1717836e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
3 deletion
+30
-3
actionview/lib/action_view/digestor.rb
actionview/lib/action_view/digestor.rb
+6
-3
actionview/test/fixtures/digestor/api/comments/_comments.json.erb
...ew/test/fixtures/digestor/api/comments/_comments.json.erb
+1
-0
actionview/test/fixtures/digestor/messages/thread.json.erb
actionview/test/fixtures/digestor/messages/thread.json.erb
+1
-0
actionview/test/template/digestor_test.rb
actionview/test/template/digestor_test.rb
+22
-0
未找到文件。
actionview/lib/action_view/digestor.rb
浏览文件 @
1ee4eebb
...
...
@@ -38,10 +38,13 @@ def logger
# Create a dependency tree for template named +name+.
def
tree
(
name
,
finder
,
partial
=
false
,
seen
=
{})
logical_name
=
name
.
gsub
(
%r|/_|
,
"/"
)
formats
=
[
finder
.
rendered_format
]
if
finder
.
disable_cache
{
finder
.
exists?
(
logical_name
,
[],
partial
,
[],
formats:
formats
)
}
template
=
finder
.
disable_cache
{
finder
.
find
(
logical_name
,
[],
partial
,
[],
formats:
formats
)
}
options
=
{}
options
[
:formats
]
=
[
finder
.
rendered_format
]
if
finder
.
rendered_format
if
finder
.
disable_cache
{
finder
.
exists?
(
logical_name
,
[],
partial
,
[],
options
)
}
template
=
finder
.
disable_cache
{
finder
.
find
(
logical_name
,
[],
partial
,
[],
options
)
}
finder
.
rendered_format
||=
template
.
formats
.
first
if
node
=
seen
[
template
.
identifier
]
# handle cycles in the tree
node
...
...
actionview/test/fixtures/digestor/api/comments/_comments.json.erb
0 → 100644
浏览文件 @
1ee4eebb
<%=
render
partial:
"comments/comment"
,
collection:
commentable
.
comments
%>
actionview/test/fixtures/digestor/messages/thread.json.erb
0 → 100644
浏览文件 @
1ee4eebb
<%=
render
"comments/comments"
%>
actionview/test/template/digestor_test.rb
浏览文件 @
1ee4eebb
...
...
@@ -22,6 +22,12 @@ def initialize(details = {})
end
end
class
ActionView::Digestor::Node
def
flatten
[
self
]
+
children
.
flat_map
(
&
:flatten
)
end
end
class
TemplateDigestorTest
<
ActionView
::
TestCase
def
setup
@cwd
=
Dir
.
pwd
...
...
@@ -148,6 +154,17 @@ def test_nested_template_deps
assert_equal
nested_deps
,
nested_dependencies
(
"messages/show"
)
end
def
test_nested_template_deps_with_non_default_rendered_format
finder
.
rendered_format
=
nil
nested_deps
=
[{
"comments/comments"
=>
[
"comments/comment"
]}]
assert_equal
nested_deps
,
nested_dependencies
(
"messages/thread"
)
end
def
test_template_formats_of_nested_deps_with_non_default_rendered_format
finder
.
rendered_format
=
nil
assert_equal
[
:json
,
:json
,
:json
],
tree_template_formats
(
"messages/thread"
)
end
def
test_recursion_in_renders
assert
digest
(
"level/recursion"
)
# assert recursion is possible
assert_not_nil
digest
(
"level/recursion"
)
# assert digest is stored
...
...
@@ -334,6 +351,11 @@ def nested_dependencies(template_name)
tree
.
children
.
map
(
&
:to_dep_map
)
end
def
tree_template_formats
(
template_name
)
tree
=
ActionView
::
Digestor
.
tree
(
template_name
,
finder
)
tree
.
flatten
.
map
(
&
:template
).
flat_map
(
&
:formats
)
end
def
disable_resolver_caching
old_caching
,
ActionView
::
Resolver
.
caching
=
ActionView
::
Resolver
.
caching
,
false
yield
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录