Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
23e35f11
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,发现更多精彩内容 >>
提交
23e35f11
编写于
7月 04, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14005 from dmitry/test_coverage_for_actionmailer
Add test coverage for the action mailer
上级
bcd1b9cd
99f8d4fe
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
16 addition
and
38 deletion
+16
-38
actionmailer/test/abstract_unit.rb
actionmailer/test/abstract_unit.rb
+3
-21
actionmailer/test/asset_host_test.rb
actionmailer/test/asset_host_test.rb
+1
-16
actionmailer/test/delivery_methods_test.rb
actionmailer/test/delivery_methods_test.rb
+1
-1
actionmailer/test/fixtures/test_helper_mailer/welcome
actionmailer/test/fixtures/test_helper_mailer/welcome
+1
-0
actionmailer/test/i18n_with_controller_test.rb
actionmailer/test/i18n_with_controller_test.rb
+1
-0
actionmailer/test/test_helper_test.rb
actionmailer/test/test_helper_test.rb
+9
-0
未找到文件。
actionmailer/test/abstract_unit.rb
浏览文件 @
23e35f11
...
...
@@ -26,27 +26,9 @@
FIXTURE_LOAD_PATH
=
File
.
expand_path
(
'fixtures'
,
File
.
dirname
(
__FILE__
))
ActionMailer
::
Base
.
view_paths
=
FIXTURE_LOAD_PATH
class
MockSMTP
def
self
.
deliveries
@@deliveries
end
def
initialize
@@deliveries
=
[]
end
def
sendmail
(
mail
,
from
,
to
)
@@deliveries
<<
[
mail
,
from
,
to
]
end
def
start
(
*
args
)
yield
self
end
end
class
Net::SMTP
def
self
.
new
(
*
args
)
MockSMTP
.
new
class
Rails
def
self
.
root
File
.
expand_path
(
'../'
,
File
.
dirname
(
__FILE__
))
end
end
...
...
actionmailer/test/asset_host_test.rb
浏览文件 @
23e35f11
...
...
@@ -31,25 +31,10 @@ def test_asset_host_as_string
def
test_asset_host_as_one_argument_proc
AssetHostMailer
.
config
.
asset_host
=
Proc
.
new
{
|
source
|
if
source
.
starts_with?
(
'/images'
)
"http://images.example.com"
else
"http://assets.example.com"
'http://images.example.com'
end
}
mail
=
AssetHostMailer
.
email_with_asset
assert_equal
%Q{<img alt="Somelogo" src="http://images.example.com/images/somelogo.png" />}
,
mail
.
body
.
to_s
.
strip
end
def
test_asset_host_as_two_argument_proc
ActionController
::
Base
.
config
.
asset_host
=
Proc
.
new
{
|
source
,
request
|
if
request
&&
request
.
ssl?
"https://www.example.com"
else
"http://www.example.com"
end
}
mail
=
nil
assert_nothing_raised
{
mail
=
AssetHostMailer
.
email_with_asset
}
assert_equal
%Q{<img alt="Somelogo" src="http://www.example.com/images/somelogo.png" />}
,
mail
.
body
.
to_s
.
strip
end
end
actionmailer/test/delivery_methods_test.rb
浏览文件 @
23e35f11
...
...
@@ -108,6 +108,7 @@ def welcome(hash={})
end
test
"delivery method can be customized per instance"
do
Mail
::
SMTP
.
any_instance
.
expects
(
:deliver!
)
email
=
DeliveryMailer
.
welcome
.
deliver
assert_instance_of
Mail
::
SMTP
,
email
.
delivery_method
email
=
DeliveryMailer
.
welcome
(
delivery_method: :test
).
deliver
...
...
@@ -117,7 +118,6 @@ def welcome(hash={})
test
"delivery method can be customized in subclasses not changing the parent"
do
DeliveryMailer
.
delivery_method
=
:test
assert_equal
:smtp
,
ActionMailer
::
Base
.
delivery_method
$BREAK
=
true
email
=
DeliveryMailer
.
welcome
.
deliver
assert_instance_of
Mail
::
TestMailer
,
email
.
delivery_method
end
...
...
actionmailer/test/fixtures/test_helper_mailer/welcome
0 → 100644
浏览文件 @
23e35f11
Welcome!
\ No newline at end of file
actionmailer/test/i18n_with_controller_test.rb
浏览文件 @
23e35f11
...
...
@@ -37,6 +37,7 @@ def app
end
def
test_send_mail
Mail
::
SMTP
.
any_instance
.
expects
(
:deliver!
)
with_translation
'de'
,
email_subject:
'[Anmeldung] Willkommen'
do
get
'/test/send_mail'
assert_equal
"Mail sent - Subject: [Anmeldung] Willkommen"
,
@response
.
body
...
...
actionmailer/test/test_helper_test.rb
浏览文件 @
23e35f11
# encoding: utf-8
require
'abstract_unit'
class
TestHelperMailer
<
ActionMailer
::
Base
...
...
@@ -36,6 +37,14 @@ def test_charset_is_utf_8
assert_equal
"UTF-8"
,
charset
end
def
test_encode
assert_equal
'=?UTF-8?Q?This_is_=E3=81=82_string?='
,
encode
(
'This is あ string'
)
end
def
test_read_fixture
assert_equal
[
'Welcome!'
],
read_fixture
(
'welcome'
)
end
def
test_assert_emails
assert_nothing_raised
do
assert_emails
1
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录