Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
af43674c
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,发现更多精彩内容 >>
提交
af43674c
编写于
1月 26, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix failing tests on AM about render(:body => Hash).
上级
bdc39fad
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
36 addition
and
68 deletion
+36
-68
actionmailer/lib/action_mailer/deprecated_api.rb
actionmailer/lib/action_mailer/deprecated_api.rb
+4
-2
actionmailer/lib/action_mailer/old_api.rb
actionmailer/lib/action_mailer/old_api.rb
+2
-6
actionmailer/test/old_base/mail_layout_test.rb
actionmailer/test/old_base/mail_layout_test.rb
+2
-2
actionmailer/test/old_base/mail_render_test.rb
actionmailer/test/old_base/mail_render_test.rb
+9
-38
actionmailer/test/old_base/mail_service_test.rb
actionmailer/test/old_base/mail_service_test.rb
+18
-19
actionmailer/test/subscriber_test.rb
actionmailer/test/subscriber_test.rb
+1
-1
未找到文件。
actionmailer/lib/action_mailer/deprecated_api.rb
浏览文件 @
af43674c
...
...
@@ -93,10 +93,12 @@ def deliver!(mail = @_message)
def
render
(
*
args
)
options
=
args
.
last
.
is_a?
(
Hash
)
?
args
.
last
:
{}
if
options
[
:body
]
if
options
[
:body
].
is_a?
(
Hash
)
ActiveSupport
::
Deprecation
.
warn
(
':body in render deprecated. Please use instance '
<<
'variables as assigns instead'
,
caller
[
0
,
1
])
body
options
.
delete
(
:body
)
options
[
:body
].
each
{
|
k
,
v
|
instance_variable_set
(
:"@
#{
k
}
"
,
v
)
}
end
super
end
...
...
actionmailer/lib/action_mailer/old_api.rb
浏览文件 @
af43674c
...
...
@@ -204,12 +204,8 @@ def initialize_defaults(method_name)
def
create_parts
if
String
===
@body
self
.
response_body
=
@body
end
if
String
===
response_body
@parts
.
unshift
create_inline_part
(
response_body
)
else
@parts
.
unshift
create_inline_part
(
@body
)
elsif
@parts
.
empty?
||
@parts
.
all?
{
|
p
|
p
.
content_disposition
=~
/^attachment/
}
self
.
class
.
view_paths
.
first
.
find_all
(
@template
,
{},
@mailer_name
).
each
do
|
template
|
@parts
<<
create_inline_part
(
render_to_body
(
:_template
=>
template
),
template
.
mime_type
)
end
...
...
actionmailer/test/old_base/mail_layout_test.rb
浏览文件 @
af43674c
...
...
@@ -14,7 +14,7 @@ def spam
from
"tester@example.com"
@world
=
"Earth"
render
(
:inline
=>
"Hello, <%= @world %>"
,
:layout
=>
'spam'
)
body
render
(
:inline
=>
"Hello, <%= @world %>"
,
:layout
=>
'spam'
)
end
def
nolayout
...
...
@@ -23,7 +23,7 @@ def nolayout
from
"tester@example.com"
@world
=
"Earth"
render
(
:inline
=>
"Hello, <%= @world %>"
,
:layout
=>
false
)
body
render
(
:inline
=>
"Hello, <%= @world %>"
,
:layout
=>
false
)
end
def
multipart
(
type
=
nil
)
...
...
actionmailer/test/old_base/mail_render_test.rb
浏览文件 @
af43674c
...
...
@@ -7,7 +7,7 @@ def inline_template
from
"tester@example.com"
@world
=
"Earth"
render
:inline
=>
"Hello, <%= @world %>"
body
render
(
:inline
=>
"Hello, <%= @world %>"
)
end
def
file_template
...
...
@@ -16,16 +16,7 @@ def file_template
from
"tester@example.com"
@recipient
=
'test@localhost'
render
:file
=>
"templates/signed_up"
end
def
implicit_body
recipients
'test@localhost'
subject
"using helpers"
from
"tester@example.com"
@recipient
=
'test@localhost'
render
:template
=>
"templates/signed_up"
body
render
(
:file
=>
"templates/signed_up"
)
end
def
rxml_template
...
...
@@ -40,21 +31,13 @@ def included_subtemplate
from
"tester@example.com"
end
def
mailer_accessor
recipients
'test@localhost'
subject
"Mailer Accessor"
from
"tester@example.com"
render
:inline
=>
"Look, <%= mailer.subject %>!"
end
def
no_instance_variable
recipients
'test@localhost'
subject
"No Instance Variable"
from
"tester@example.com"
silence_warnings
do
render
:inline
=>
"Look, subject.nil? is <%= @subject.nil? %>!"
body
render
(
:inline
=>
"Look, subject.nil? is <%= @subject.nil? %>!"
)
end
end
...
...
@@ -81,13 +64,11 @@ def build_multipart_message(assigns = {})
part
"text/html"
do
|
p
|
p
.
body
=
build_body_part
(
'html'
,
assigns
)
p
.
transfer_encoding
=
"base64"
end
end
def
build_body_part
(
content_type
,
assigns
,
options
=
{})
render
"
#{
template
}
.
#{
content_type
}
"
,
:body
=>
assigns
# render options.merge(:file => "#{template}.#{content_type}", :body => assigns)
end
end
...
...
@@ -122,11 +103,6 @@ def teardown
restore_delivery_method
end
def
test_implicit_body
mail
=
RenderMailer
.
implicit_body
assert_equal
"Hello there,
\n\n
Mr. test@localhost"
,
mail
.
body
.
to_s
.
strip
end
def
test_inline_template
mail
=
RenderMailer
.
inline_template
assert_equal
"Hello, Earth"
,
mail
.
body
.
to_s
.
strip
...
...
@@ -147,11 +123,6 @@ def test_included_subtemplate
assert_equal
"Hey Ho, let's go!"
,
mail
.
body
.
to_s
.
strip
end
def
test_mailer_accessor
mail
=
RenderMailer
.
mailer_accessor
.
deliver
assert_equal
"Look, Mailer Accessor!"
,
mail
.
body
.
to_s
.
strip
end
def
test_no_instance_variable
mail
=
RenderMailer
.
no_instance_variable
.
deliver
assert_equal
"Look, subject.nil? is true!"
,
mail
.
body
.
to_s
.
strip
...
...
@@ -159,12 +130,12 @@ def test_no_instance_variable
def
test_legacy_multipart_alternative
mail
=
RenderMailer
.
multipart_alternative
.
deliver
assert_equal
(
2
,
e
mail
.
parts
.
size
)
assert_equal
(
"multipart/alternative"
,
e
mail
.
mime_type
)
assert_equal
(
"text/plain"
,
e
mail
.
parts
[
0
].
mime_type
)
assert_equal
(
"foo: bar"
,
e
mail
.
parts
[
0
].
body
.
encoded
)
assert_equal
(
"text/html"
,
e
mail
.
parts
[
1
].
mime_type
)
assert_equal
(
"<strong>foo</strong> bar"
,
e
mail
.
parts
[
1
].
body
.
encoded
)
assert_equal
(
2
,
mail
.
parts
.
size
)
assert_equal
(
"multipart/alternative"
,
mail
.
mime_type
)
assert_equal
(
"text/plain"
,
mail
.
parts
[
0
].
mime_type
)
assert_equal
(
"foo: bar"
,
mail
.
parts
[
0
].
body
.
encoded
)
assert_equal
(
"text/html"
,
mail
.
parts
[
1
].
mime_type
)
assert_equal
(
"<strong>foo</strong> bar"
,
mail
.
parts
[
1
].
body
.
encoded
)
end
end
...
...
actionmailer/test/old_base/mail_service_test.rb
浏览文件 @
af43674c
...
...
@@ -27,20 +27,19 @@ def cancelled_account(recipient)
subject
"[Cancelled] Goodbye
#{
recipient
}
"
from
"system@loudthinking.com"
sent_on
Time
.
local
(
2004
,
12
,
12
)
render
:text
=>
"Goodbye, Mr.
#{
recipient
}
"
body
"Goodbye, Mr.
#{
recipient
}
"
end
def
from_with_name
from
"System <system@loudthinking.com>"
recipients
"root@loudthinking.com"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
from_without_name
from
"system@loudthinking.com"
recipients
"root@loudthinking.com"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
cc_bcc
(
recipient
)
...
...
@@ -51,7 +50,7 @@ def cc_bcc(recipient)
cc
"nobody@loudthinking.com"
bcc
"root@loudthinking.com"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
different_reply_to
(
recipient
)
...
...
@@ -61,7 +60,7 @@ def different_reply_to(recipient)
sent_on
Time
.
local
(
2008
,
5
,
23
)
reply_to
"atraver@gmail.com"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
iso_charset
(
recipient
)
...
...
@@ -73,7 +72,7 @@ def iso_charset(recipient)
bcc
"root@loudthinking.com"
charset
"iso-8859-1"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
unencoded_subject
(
recipient
)
...
...
@@ -84,7 +83,7 @@ def unencoded_subject(recipient)
cc
"nobody@loudthinking.com"
bcc
"root@loudthinking.com"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
extended_headers
(
recipient
)
...
...
@@ -96,7 +95,7 @@ def extended_headers(recipient)
bcc
"Grytøyr <stian3@example.net>"
charset
"iso-8859-1"
render
:text
=>
"Nothing to see here."
body
"Nothing to see here."
end
def
utf8_body
(
recipient
)
...
...
@@ -108,7 +107,7 @@ def utf8_body(recipient)
bcc
"Foo áëô îü <extended@example.net>"
charset
"utf-8"
render
:text
=>
"åœö blah"
body
"åœö blah"
end
def
multipart_with_mime_version
(
recipient
)
...
...
@@ -158,7 +157,7 @@ def explicitly_multipart_example(recipient, ct=nil)
attachment
:content_type
=>
"image/jpeg"
,
:filename
=>
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures"
,
"attachments"
,
"foo.jpg"
),
:data
=>
"123456789"
render
:text
=>
"plain text default"
body
"plain text default"
end
def
implicitly_multipart_example
(
recipient
,
cs
=
nil
,
order
=
nil
)
...
...
@@ -187,12 +186,12 @@ def html_mail(recipient)
from
"test@example.com"
content_type
"text/html"
render
:text
=>
"<em>Emphasize</em> <strong>this</strong>"
body
"<em>Emphasize</em> <strong>this</strong>"
end
def
html_mail_with_underscores
(
recipient
)
subject
"html mail with underscores"
render
:text
=>
%{<a href="http://google.com" target="_blank">_Google</a>}
body
%{<a href="http://google.com" target="_blank">_Google</a>}
end
def
custom_template
(
recipient
)
...
...
@@ -219,7 +218,7 @@ def various_newlines(recipient)
subject
"various newlines"
from
"test@example.com"
render
:text
=>
"line #1
\n
line #2
\r
line #3
\r\n
line #4
\r\r
"
+
body
"line #1
\n
line #2
\r
line #3
\r\n
line #4
\r\r
"
+
"line #5
\n\n
line#6
\r\n\r\n
line #7"
end
...
...
@@ -282,7 +281,7 @@ def headers_with_nonalpha_chars(recipient)
from
"One: Two <test@example.com>"
cc
"Three: Four <test@example.com>"
bcc
"Five: Six <test@example.com>"
render
:text
=>
"testing"
body
"testing"
end
def
custom_content_type_attributes
...
...
@@ -290,7 +289,7 @@ def custom_content_type_attributes
subject
"custom content types"
from
"some.one@somewhere.test"
content_type
"text/plain; format=flowed"
render
:text
=>
"testing"
body
"testing"
end
def
return_path
...
...
@@ -298,13 +297,13 @@ def return_path
subject
"return path test"
from
"some.one@somewhere.test"
headers
[
"return-path"
]
=
"another@somewhere.test"
render
:text
=>
"testing"
body
"testing"
end
def
subject_with_i18n
(
recipient
)
recipients
recipient
from
"system@loudthinking.com"
render
:text
=>
"testing"
body
"testing"
end
class
<<
self
...
...
@@ -1111,7 +1110,7 @@ def test_attr
class
MethodNamingTest
<
ActiveSupport
::
TestCase
class
TestMailer
<
ActionMailer
::
Base
def
send
render
:text
=>
'foo'
body
'foo'
end
end
...
...
actionmailer/test/subscriber_test.rb
浏览文件 @
af43674c
...
...
@@ -11,7 +11,7 @@ def basic
recipients
"somewhere@example.com"
subject
"basic"
from
"basic@example.com"
render
:text
=>
"Hello world"
body
"Hello world"
end
def
receive
(
mail
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录