提交 96747036 编写于 作者: A Arthur Nogueira Neves

Merge pull request #17388 from akampjes/master

ActionMailer https on URL with force_ssl = true
* `config.force_ssl = true` will set
`config.action_mailer.default_url_options = { protocol: 'https' }`
*Andrew Kampjes*
* Add `config.action_mailer.deliver_later_queue_name` configuration to set the
mailer queue name.
......
......@@ -132,6 +132,8 @@ module ActionMailer
#
# config.action_mailer.default_url_options = { host: "example.com" }
#
# By default when <tt>config.force_ssl</tt> is true, URLs generated for hosts will use the HTTPS protocol.
#
# = Sending mail
#
# Once a mailer action and template are defined, you can deliver your message or defer its creation and
......
......@@ -16,6 +16,11 @@ class Railtie < Rails::Railtie # :nodoc:
paths = app.config.paths
options = app.config.action_mailer
if app.config.force_ssl
options.default_url_options ||= {}
options.default_url_options[:protocol] ||= 'https'
end
options.assets_dir ||= paths["public"].first
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
......
......@@ -49,6 +49,17 @@ def teardown
assert_equal "test.rails", ActionMailer::Base.default_url_options[:host]
end
test "Default to HTTPS for ActionMailer URLs when force_ssl is on" do
app_file "config/environments/development.rb", <<-RUBY
Rails.application.configure do
config.force_ssl = true
end
RUBY
require "#{app_path}/config/environment"
assert_equal "https", ActionMailer::Base.default_url_options[:protocol]
end
test "includes url helpers as action methods" do
app_file "config/routes.rb", <<-RUBY
Rails.application.routes.draw do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册