Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f2a8c236
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 搜索 >>
提交
f2a8c236
编写于
7月 05, 2015
作者:
K
Kasper Timm Hansen
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20758 from xijo/action_mailer_message_delivery_respects_i18n_locale
ActionMailer::MessageDelivery respects current I18n.locale
上级
3046c9bb
ca2387eb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
9 deletion
+25
-9
actionmailer/CHANGELOG.md
actionmailer/CHANGELOG.md
+6
-0
actionmailer/lib/action_mailer/delivery_job.rb
actionmailer/lib/action_mailer/delivery_job.rb
+4
-2
actionmailer/lib/action_mailer/message_delivery.rb
actionmailer/lib/action_mailer/message_delivery.rb
+1
-1
actionmailer/test/message_delivery_test.rb
actionmailer/test/message_delivery_test.rb
+14
-6
未找到文件。
actionmailer/CHANGELOG.md
浏览文件 @
f2a8c236
*
`deliver_later`
now respects the current locale.
Fixes #20774.
*Johannes Opper*
*
Add
`config.action_mailer.deliver_later_queue_name`
configuration to set the
mailer queue name.
...
...
actionmailer/lib/action_mailer/delivery_job.rb
浏览文件 @
f2a8c236
...
...
@@ -6,8 +6,10 @@ module ActionMailer
class
DeliveryJob
<
ActiveJob
::
Base
# :nodoc:
queue_as
{
ActionMailer
::
Base
.
deliver_later_queue_name
}
def
perform
(
mailer
,
mail_method
,
delivery_method
,
*
args
)
#:nodoc:
mailer
.
constantize
.
public_send
(
mail_method
,
*
args
).
send
(
delivery_method
)
def
perform
(
mailer
,
mail_method
,
delivery_method
,
locale
,
*
args
)
#:nodoc:
I18n
.
with_locale
(
locale
)
do
mailer
.
constantize
.
public_send
(
mail_method
,
*
args
).
send
(
delivery_method
)
end
end
end
end
actionmailer/lib/action_mailer/message_delivery.rb
浏览文件 @
f2a8c236
...
...
@@ -87,7 +87,7 @@ def deliver_now
private
def
enqueue_delivery
(
delivery_method
,
options
=
{})
args
=
@mailer
.
name
,
@mail_method
.
to_s
,
delivery_method
.
to_s
,
*
@args
args
=
@mailer
.
name
,
@mail_method
.
to_s
,
delivery_method
.
to_s
,
I18n
.
locale
.
to_s
,
*
@args
ActionMailer
::
DeliveryJob
.
set
(
options
).
perform_later
(
*
args
)
end
end
...
...
actionmailer/test/message_delivery_test.rb
浏览文件 @
f2a8c236
...
...
@@ -57,20 +57,20 @@ def test_should_enqueue_and_run_correctly_in_activejob
end
test
'should enqueue the email with :deliver_now delivery method'
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
1
,
2
,
3
])
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
'en'
,
1
,
2
,
3
])
do
@mail
.
deliver_later
end
end
test
'should enqueue the email with :deliver_now! delivery method'
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now!'
,
1
,
2
,
3
])
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now!'
,
'en'
,
1
,
2
,
3
])
do
@mail
.
deliver_later!
end
end
test
'should enqueue a delivery with a delay'
do
travel_to
Time
.
new
(
2004
,
11
,
24
,
01
,
04
,
44
)
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
at:
Time
.
current
.
to_f
+
600
.
seconds
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
1
,
2
,
3
])
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
at:
Time
.
current
.
to_f
+
600
.
seconds
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
'en'
,
1
,
2
,
3
])
do
@mail
.
deliver_later
wait:
600
.
seconds
end
end
...
...
@@ -78,20 +78,28 @@ def test_should_enqueue_and_run_correctly_in_activejob
test
'should enqueue a delivery at a specific time'
do
later_time
=
Time
.
now
.
to_f
+
3600
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
at:
later_time
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
1
,
2
,
3
])
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
at:
later_time
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
'en'
,
1
,
2
,
3
])
do
@mail
.
deliver_later
wait_until:
later_time
end
end
test
'should enqueue the job on the correct queue'
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
1
,
2
,
3
],
queue:
"test_queue"
)
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
'en'
,
1
,
2
,
3
],
queue:
"test_queue"
)
do
@mail
.
deliver_later
end
end
test
'can override the queue when enqueuing mail'
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
1
,
2
,
3
],
queue:
"another_queue"
)
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
'en'
,
1
,
2
,
3
],
queue:
"another_queue"
)
do
@mail
.
deliver_later
(
queue: :another_queue
)
end
end
test
'should enqueue a delivery with the correct locale'
do
I18n
.
with_locale
(
'de'
)
do
assert_performed_with
(
job:
ActionMailer
::
DeliveryJob
,
args:
[
'DelayedMailer'
,
'test_message'
,
'deliver_now'
,
'de'
,
1
,
2
,
3
])
do
@mail
.
deliver_later
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录