Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c985a0ee
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,发现更多精彩内容 >>
提交
c985a0ee
编写于
1月 23, 2010
作者:
J
José Valim and Mikel Lindsaar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some tests to collector with templates and any.
上级
6ba94460
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
14 deletion
+50
-14
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+1
-1
actionmailer/lib/action_mailer/collector.rb
actionmailer/lib/action_mailer/collector.rb
+1
-2
actionmailer/test/base_test.rb
actionmailer/test/base_test.rb
+46
-11
actionmailer/test/fixtures/base_mailer/explicit_multipart_templates.html.erb
...ixtures/base_mailer/explicit_multipart_templates.html.erb
+1
-0
actionmailer/test/fixtures/base_mailer/explicit_multipart_templates.text.erb
...ixtures/base_mailer/explicit_multipart_templates.text.erb
+1
-0
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
c985a0ee
...
...
@@ -2,6 +2,7 @@
require
'active_support/core_ext/module/delegation'
require
'mail'
require
'action_mailer/tmail_compat'
require
'action_mailer/collector'
module
ActionMailer
#:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
...
...
@@ -442,7 +443,6 @@ def mail(headers = {})
end
content_type
||=
create_parts_from_responses
(
m
,
responses
,
charset
)
m
.
content_type
=
content_type
m
.
charset
=
charset
m
.
mime_version
=
mime_version
...
...
actionmailer/lib/action_mailer/collector.rb
浏览文件 @
c985a0ee
...
...
@@ -14,11 +14,10 @@ def initialize(context, &block)
@default_formats
=
context
.
formats
end
# TODO Test me
def
any
(
*
args
,
&
block
)
options
=
args
.
extract_options!
raise
"You have to supply at least one format"
if
args
.
empty?
args
.
each
{
|
type
|
send
(
type
,
options
,
&
block
)
}
args
.
each
{
|
type
|
send
(
type
,
options
.
dup
,
&
block
)
}
end
alias
:all
:any
...
...
actionmailer/test/base_test.rb
浏览文件 @
c985a0ee
...
...
@@ -77,7 +77,19 @@ def explicit_multipart(hash = {})
format
.
html
{
render
:text
=>
"HTML Explicit Multipart"
}
end
end
def
explicit_multipart_templates
(
hash
=
{})
mail
(
DEFAULT_HEADERS
.
merge
(
hash
))
do
|
format
|
format
.
html
format
.
text
end
end
def
explicit_multipart_with_any
(
hash
=
{})
mail
(
DEFAULT_HEADERS
.
merge
(
hash
))
do
|
format
|
format
.
any
(
:text
,
:html
){
render
:text
=>
"Format with any!"
}
end
end
end
test
"method call to mail does not raise error"
do
...
...
@@ -214,7 +226,7 @@ def explicit_multipart(hash = {})
end
# Implicit multipart
test
"implicit multipart
tests
"
do
test
"implicit multipart"
do
email
=
BaseMailer
.
deliver_implicit_multipart
assert_equal
(
2
,
email
.
parts
.
size
)
assert_equal
(
"multipart/alternate"
,
email
.
mime_type
)
...
...
@@ -224,7 +236,7 @@ def explicit_multipart(hash = {})
assert_equal
(
"HTML Implicit Multipart"
,
email
.
parts
[
1
].
body
.
encoded
)
end
test
"implicit multipart
tests
with sort order"
do
test
"implicit multipart with sort order"
do
order
=
[
"text/html"
,
"text/plain"
]
swap
BaseMailer
,
:default_implicit_parts_order
=>
order
do
email
=
BaseMailer
.
deliver_implicit_multipart
...
...
@@ -258,7 +270,8 @@ def explicit_multipart(hash = {})
end
end
test
"explicit multipart tests"
do
# Explicit multipart
test
"explicit multipart"
do
email
=
BaseMailer
.
deliver_explicit_multipart
assert_equal
(
2
,
email
.
parts
.
size
)
assert_equal
(
"multipart/alternate"
,
email
.
mime_type
)
...
...
@@ -282,15 +295,37 @@ def explicit_multipart(hash = {})
end
test
"explicit multipart with attachments creates nested parts"
do
email
=
BaseMailer
.
deliver_explicit_multipart
(
:attachments
=>
true
)
assert_equal
(
"application/pdf"
,
email
.
parts
[
0
].
mime_type
)
assert_equal
(
"multipart/alternate"
,
email
.
parts
[
1
].
mime_type
)
assert_equal
(
"text/plain"
,
email
.
parts
[
1
].
parts
[
0
].
mime_type
)
assert_equal
(
"TEXT Explicit Multipart"
,
email
.
parts
[
1
].
parts
[
0
].
body
.
encoded
)
assert_equal
(
"text/html"
,
email
.
parts
[
1
].
parts
[
1
].
mime_type
)
assert_equal
(
"HTML Explicit Multipart"
,
email
.
parts
[
1
].
parts
[
1
].
body
.
encoded
)
email
=
BaseMailer
.
deliver_explicit_multipart
(
:attachments
=>
true
)
assert_equal
(
"application/pdf"
,
email
.
parts
[
0
].
mime_type
)
assert_equal
(
"multipart/alternate"
,
email
.
parts
[
1
].
mime_type
)
assert_equal
(
"text/plain"
,
email
.
parts
[
1
].
parts
[
0
].
mime_type
)
assert_equal
(
"TEXT Explicit Multipart"
,
email
.
parts
[
1
].
parts
[
0
].
body
.
encoded
)
assert_equal
(
"text/html"
,
email
.
parts
[
1
].
parts
[
1
].
mime_type
)
assert_equal
(
"HTML Explicit Multipart"
,
email
.
parts
[
1
].
parts
[
1
].
body
.
encoded
)
end
# TODO Seems Mail is sorting the templates automatically, and not on demand
# test "explicit multipart with templates" do
# email = BaseMailer.deliver_explicit_multipart_templates
# assert_equal(2, email.parts.size)
# assert_equal("multipart/alternate", email.mime_type)
# assert_equal("text/html", email.parts[0].mime_type)
# assert_equal("HTML Explicit Multipart Templates", email.parts[0].body.encoded)
# assert_equal("text/plain", email.parts[1].mime_type)
# assert_equal("TEXT Explicit Multipart Templates", email.parts[1].body.encoded)
# end
test
"explicit multipart with any"
do
email
=
BaseMailer
.
deliver_explicit_multipart_with_any
assert_equal
(
2
,
email
.
parts
.
size
)
assert_equal
(
"multipart/alternate"
,
email
.
mime_type
)
assert_equal
(
"text/plain"
,
email
.
parts
[
0
].
mime_type
)
assert_equal
(
"Format with any!"
,
email
.
parts
[
0
].
body
.
encoded
)
assert_equal
(
"text/html"
,
email
.
parts
[
1
].
mime_type
)
assert_equal
(
"Format with any!"
,
email
.
parts
[
1
].
body
.
encoded
)
end
protected
# Execute the block setting the given values and restoring old values after
...
...
actionmailer/test/fixtures/base_mailer/explicit_multipart_templates.html.erb
0 → 100644
浏览文件 @
c985a0ee
HTML Explicit Multipart Templates
\ No newline at end of file
actionmailer/test/fixtures/base_mailer/explicit_multipart_templates.text.erb
0 → 100644
浏览文件 @
c985a0ee
TEXT Explicit Multipart Templates
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录