Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
063bc008
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 搜索 >>
提交
063bc008
编写于
5月 05, 2016
作者:
R
Rafael França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #24589 from vipulnsward/am-fragment-cache
Expand on Action Mailer Fragment caching tests
上级
9c86a180
cbb25c4b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
3 deletion
+62
-3
actionmailer/test/caching_test.rb
actionmailer/test/caching_test.rb
+45
-3
actionmailer/test/fixtures/caching_mailer/fragment_caching_options.html.erb
...fixtures/caching_mailer/fragment_caching_options.html.erb
+3
-0
actionmailer/test/fixtures/caching_mailer/multipart_cache.html.erb
...ler/test/fixtures/caching_mailer/multipart_cache.html.erb
+3
-0
actionmailer/test/fixtures/caching_mailer/multipart_cache.text.erb
...ler/test/fixtures/caching_mailer/multipart_cache.text.erb
+3
-0
actionmailer/test/mailers/caching_mailer.rb
actionmailer/test/mailers/caching_mailer.rb
+8
-0
未找到文件。
actionmailer/test/caching_test.rb
浏览文件 @
063bc008
...
...
@@ -125,15 +125,16 @@ def test_fragment_caching
expected_body
=
"
\"
Welcome
\"
"
assert_match
expected_body
,
email
.
body
.
encoded
assert_match
"
\"
Welcome
\"
"
,
assert_match
expected_body
,
@store
.
read
(
"views/caching/
#{
template_digest
(
"caching_mailer/fragment_cache"
)
}
"
)
end
def
test_fragment_caching_in_partials
email
=
@mailer
.
fragment_cache_in_partials
assert_match
(
/Old fragment caching in a partial/
,
email
.
body
.
encoded
)
expected_body
=
'Old fragment caching in a partial'
assert_match
(
expected_body
,
email
.
body
.
encoded
)
assert_match
(
"Old fragment caching in a partial"
,
assert_match
(
expected_body
,
@store
.
read
(
"views/caching/
#{
template_digest
(
"caching_mailer/_partial"
)
}
"
))
end
...
...
@@ -145,6 +146,47 @@ def test_skip_fragment_cache_digesting
assert_match
expected_body
,
@store
.
read
(
"views/no_digest"
)
end
def
test_fragment_caching_options
time
=
Time
.
now
email
=
@mailer
.
fragment_caching_options
expected_body
=
"No Digest"
assert_match
expected_body
,
email
.
body
.
encoded
Time
.
stub
(
:now
,
time
+
11
)
do
assert_nil
@store
.
read
(
"views/no_digest"
)
end
end
def
test_multipart_fragment_caching
email
=
@mailer
.
multipart_cache
expected_text_body
=
"
\"
Welcome text
\"
"
expected_html_body
=
"
\"
Welcome html
\"
"
encoded_body
=
email
.
body
.
encoded
assert_match
expected_text_body
,
encoded_body
assert_match
expected_html_body
,
encoded_body
assert_match
expected_text_body
,
@store
.
read
(
"views/text_caching"
)
assert_match
expected_html_body
,
@store
.
read
(
"views/html_caching"
)
end
def
test_fragment_cache_instrumentation
payload
=
nil
subscriber
=
proc
do
|*
args
|
event
=
ActiveSupport
::
Notifications
::
Event
.
new
(
*
args
)
payload
=
event
.
payload
end
ActiveSupport
::
Notifications
.
subscribed
(
subscriber
,
"read_fragment.action_mailer"
)
do
@mailer
.
fragment_cache
end
assert_equal
"caching_mailer"
,
payload
[
:mailer
]
assert_equal
"views/caching/
#{
template_digest
(
"caching_mailer/fragment_cache"
)
}
"
,
payload
[
:key
]
end
private
def
template_digest
(
name
)
...
...
actionmailer/test/fixtures/caching_mailer/fragment_caching_options.html.erb
0 → 100644
浏览文件 @
063bc008
<%=
cache
:no_digest
,
skip_digest:
true
,
expires_in:
0
do
%>
No Digest
<%
end
%>
actionmailer/test/fixtures/caching_mailer/multipart_cache.html.erb
0 → 100644
浏览文件 @
063bc008
<%
cache
:html_caching
,
skip_digest:
true
do
%>
"Welcome html"
<%
end
%>
actionmailer/test/fixtures/caching_mailer/multipart_cache.text.erb
0 → 100644
浏览文件 @
063bc008
<%
cache
:text_caching
,
skip_digest:
true
do
%>
"Welcome text"
<%
end
%>
actionmailer/test/mailers/caching_mailer.rb
浏览文件 @
063bc008
...
...
@@ -12,4 +12,12 @@ def fragment_cache_in_partials
def
skip_fragment_cache_digesting
mail
(
subject:
"welcome"
,
template_name:
"skip_fragment_cache_digesting"
)
end
def
fragment_caching_options
mail
(
subject:
"welcome"
,
template_name:
"fragment_caching_options"
)
end
def
multipart_cache
mail
(
subject:
"welcome"
,
template_name:
"multipart_cache"
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录