Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e193acb1
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,发现更多精彩内容 >>
未验证
提交
e193acb1
编写于
12月 05, 2019
作者:
K
Kasper Timm Hansen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #37666
Closes #37666
上级
d2f53ac5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
1 deletion
+38
-1
actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb
...tion_view/renderer/partial_renderer/collection_caching.rb
+1
-1
actionview/test/activerecord/multifetch_cache_test.rb
actionview/test/activerecord/multifetch_cache_test.rb
+4
-0
actionview/test/template/log_subscriber_test.rb
actionview/test/template/log_subscriber_test.rb
+7
-0
actionview/test/template/render_test.rb
actionview/test/template/render_test.rb
+26
-0
未找到文件。
actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb
浏览文件 @
e193acb1
...
...
@@ -12,7 +12,7 @@ module CollectionCaching # :nodoc:
private
def
cache_collection_render
(
instrumentation_payload
,
view
,
template
)
return
yield
unless
@options
[
:cached
]
return
yield
unless
@options
[
:cached
]
&&
view
.
controller
.
respond_to?
(
:perform_caching
)
&&
view
.
controller
.
perform_caching
# Result is a hash with the key represents the
# key used for cache lookup and the value is the item
...
...
actionview/test/activerecord/multifetch_cache_test.rb
浏览文件 @
e193acb1
...
...
@@ -22,6 +22,10 @@ def combined_fragment_cache_key(key)
[
:views
,
key
]
end
end
.
with_view_paths
(
view_paths
,
{})
controller
=
ActionController
::
Base
.
new
controller
.
perform_caching
=
true
@view
.
controller
=
controller
end
def
test_only_preloading_for_records_that_miss_the_cache
...
...
actionview/test/template/log_subscriber_test.rb
浏览文件 @
e193acb1
...
...
@@ -194,6 +194,8 @@ def test_render_partial_with_cache_hitted_and_missed
def
test_render_collection_template
Rails
.
stub
(
:root
,
File
.
expand_path
(
FIXTURE_LOAD_PATH
))
do
set_cache_controller
@view
.
render
(
partial:
"test/customer"
,
collection:
[
Customer
.
new
(
"david"
),
Customer
.
new
(
"mary"
)
])
wait
...
...
@@ -204,6 +206,8 @@ def test_render_collection_template
def
test_render_collection_with_implicit_path
Rails
.
stub
(
:root
,
File
.
expand_path
(
FIXTURE_LOAD_PATH
))
do
set_cache_controller
@view
.
render
([
Customer
.
new
(
"david"
),
Customer
.
new
(
"mary"
)
],
greeting:
"hi"
)
wait
...
...
@@ -214,6 +218,8 @@ def test_render_collection_with_implicit_path
def
test_render_collection_template_without_path
Rails
.
stub
(
:root
,
File
.
expand_path
(
FIXTURE_LOAD_PATH
))
do
set_cache_controller
@view
.
render
([
GoodCustomer
.
new
(
"david"
),
Customer
.
new
(
"mary"
)
],
greeting:
"hi"
)
wait
...
...
@@ -225,6 +231,7 @@ def test_render_collection_template_without_path
def
test_render_collection_with_cached_set
Rails
.
stub
(
:root
,
File
.
expand_path
(
FIXTURE_LOAD_PATH
))
do
set_view_cache_dependencies
set_cache_controller
@view
.
render
(
partial:
"customers/customer"
,
collection:
[
Customer
.
new
(
"david"
),
Customer
.
new
(
"mary"
)
],
cached:
true
,
locals:
{
greeting:
"hi"
})
...
...
actionview/test/template/render_test.rb
浏览文件 @
e193acb1
...
...
@@ -19,6 +19,8 @@ def combined_fragment_cache_key(key)
end
.
with_view_paths
(
paths
,
@assigns
)
controller
=
TestController
.
new
controller
.
perform_caching
=
true
@view
.
controller
=
controller
@controller_view
=
controller
.
view_context_class
.
with_empty_template_cache
.
new
(
controller
.
lookup_context
,
...
...
@@ -785,6 +787,30 @@ def teardown
@view
.
render
(
partial:
"test/customer"
,
collection:
[
customer
])
end
test
"collection caching does not cache if controller doesn't respond to perform_caching"
do
@view
.
controller
=
nil
customer
=
Customer
.
new
(
"david"
,
1
)
key
=
cache_key
(
customer
,
"test/_customer"
)
ActionView
::
PartialRenderer
.
collection_cache
.
write
(
key
,
"Cached"
)
assert_not_equal
"Cached"
,
@view
.
render
(
partial:
"test/customer"
,
collection:
[
customer
],
cached:
true
)
end
test
"collection caching does not cache if perform_caching is disabled"
do
@view
.
controller
.
perform_caching
=
false
customer
=
Customer
.
new
(
"david"
,
1
)
key
=
cache_key
(
customer
,
"test/_customer"
)
ActionView
::
PartialRenderer
.
collection_cache
.
write
(
key
,
"Cached"
)
assert_not_equal
"Cached"
,
@view
.
render
(
partial:
"test/customer"
,
collection:
[
customer
],
cached:
true
)
end
test
"collection caching with partial that doesn't use fragment caching"
do
customer
=
Customer
.
new
(
"david"
,
1
)
key
=
cache_key
(
customer
,
"test/_customer"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录