Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
cecbf9ed
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,发现更多精彩内容 >>
提交
cecbf9ed
编写于
6月 03, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18587 from chrismcg/allow_deliver_later_queue_name_to_be_configured
Allow configuration of ActionMailer queue name
上级
6c441618
f5a131aa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
1 deletion
+33
-1
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+2
-0
actionmailer/lib/action_mailer/delivery_job.rb
actionmailer/lib/action_mailer/delivery_job.rb
+1
-1
actionmailer/lib/action_mailer/delivery_methods.rb
actionmailer/lib/action_mailer/delivery_methods.rb
+3
-0
actionmailer/test/message_delivery_test.rb
actionmailer/test/message_delivery_test.rb
+14
-0
railties/test/application/configuration_test.rb
railties/test/application/configuration_test.rb
+13
-0
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
cecbf9ed
...
...
@@ -413,6 +413,8 @@ module ActionMailer
#
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with
# <tt>delivery_method :test</tt>. Most useful for unit and functional testing.
#
# * <tt>deliver_later_queue_name</tt> - The name of the queue used with <tt>deliver_later</tt>
class
Base
<
AbstractController
::
Base
include
DeliveryMethods
include
Previews
...
...
actionmailer/lib/action_mailer/delivery_job.rb
浏览文件 @
cecbf9ed
...
...
@@ -4,7 +4,7 @@ module ActionMailer
# The <tt>ActionMailer::DeliveryJob</tt> class is used when you
# want to send emails outside of the request-response cycle.
class
DeliveryJob
<
ActiveJob
::
Base
# :nodoc:
queue_as
:mailers
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
)
...
...
actionmailer/lib/action_mailer/delivery_methods.rb
浏览文件 @
cecbf9ed
...
...
@@ -16,6 +16,9 @@ module DeliveryMethods
cattr_accessor
:perform_deliveries
self
.
perform_deliveries
=
true
cattr_accessor
:deliver_later_queue_name
self
.
deliver_later_queue_name
=
:mailers
self
.
delivery_methods
=
{}.
freeze
self
.
delivery_method
=
:smtp
...
...
actionmailer/test/message_delivery_test.rb
浏览文件 @
cecbf9ed
...
...
@@ -9,6 +9,8 @@ class MessageDeliveryTest < ActiveSupport::TestCase
setup
do
@previous_logger
=
ActiveJob
::
Base
.
logger
@previous_delivery_method
=
ActionMailer
::
Base
.
delivery_method
@previous_deliver_later_queue_name
=
ActionMailer
::
Base
.
deliver_later_queue_name
ActionMailer
::
Base
.
deliver_later_queue_name
=
:test_queue
ActionMailer
::
Base
.
delivery_method
=
:test
ActiveJob
::
Base
.
logger
=
Logger
.
new
(
nil
)
@mail
=
DelayedMailer
.
test_message
(
1
,
2
,
3
)
...
...
@@ -20,6 +22,7 @@ class MessageDeliveryTest < ActiveSupport::TestCase
teardown
do
ActiveJob
::
Base
.
logger
=
@previous_logger
ActionMailer
::
Base
.
delivery_method
=
@previous_delivery_method
ActionMailer
::
Base
.
deliver_later_queue_name
=
@previous_deliver_later_queue_name
end
test
'should have a message'
do
...
...
@@ -80,4 +83,15 @@ def test_should_enqueue_and_run_correctly_in_activejob
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
@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
@mail
.
deliver_later
(
queue: :another_queue
)
end
end
end
railties/test/application/configuration_test.rb
浏览文件 @
cecbf9ed
...
...
@@ -745,6 +745,19 @@ def index
assert_equal
[
::
MyMailObserver
,
::
MyOtherMailObserver
],
::
Mail
.
send
(
:class_variable_get
,
"@@delivery_notification_observers"
)
end
test
"allows setting the queue name for the ActionMailer::DeliveryJob"
do
add_to_config
<<-
RUBY
config.action_mailer.deliver_later_queue_name = 'test_default'
RUBY
require
"
#{
app_path
}
/config/environment"
require
"mail"
_
=
ActionMailer
::
Base
assert_equal
'test_default'
,
ActionMailer
::
Base
.
send
(
:class_variable_get
,
"@@deliver_later_queue_name"
)
end
test
"valid timezone is setup correctly"
do
add_to_config
<<-
RUBY
config.root = "
#{
app_path
}
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录