mirror of https://github.com/rails/rails
Only configure smtp_settings if provided on configuration
This commit is contained in:
parent
5c1bd20f0d
commit
921263bb92
|
@ -23,7 +23,6 @@ module ActionMailer
|
||||||
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
||||||
options.show_previews = Rails.env.development? if options.show_previews.nil?
|
options.show_previews = Rails.env.development? if options.show_previews.nil?
|
||||||
options.cache_store ||= Rails.cache
|
options.cache_store ||= Rails.cache
|
||||||
options.smtp_settings ||= {}
|
|
||||||
|
|
||||||
if options.show_previews
|
if options.show_previews
|
||||||
options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
|
options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
|
||||||
|
@ -46,9 +45,15 @@ module ActionMailer
|
||||||
self.delivery_job = delivery_job.constantize
|
self.delivery_job = delivery_job.constantize
|
||||||
end
|
end
|
||||||
|
|
||||||
if smtp_timeout = options.delete(:smtp_timeout)
|
if options.smtp_settings
|
||||||
options.smtp_settings[:open_timeout] ||= smtp_timeout
|
self.smtp_settings = options.smtp_settings
|
||||||
options.smtp_settings[:read_timeout] ||= smtp_timeout
|
end
|
||||||
|
|
||||||
|
smtp_timeout = options.delete(:smtp_timeout)
|
||||||
|
|
||||||
|
if self.smtp_settings && smtp_timeout
|
||||||
|
self.smtp_settings[:open_timeout] ||= smtp_timeout
|
||||||
|
self.smtp_settings[:read_timeout] ||= smtp_timeout
|
||||||
end
|
end
|
||||||
|
|
||||||
options.each { |k, v| send("#{k}=", v) }
|
options.each { |k, v| send("#{k}=", v) }
|
||||||
|
|
|
@ -2799,7 +2799,36 @@ module ApplicationTests
|
||||||
smtp_settings = { domain: "example.com" }
|
smtp_settings = { domain: "example.com" }
|
||||||
|
|
||||||
assert_equal smtp_settings, ActionMailer::Base.smtp_settings
|
assert_equal smtp_settings, ActionMailer::Base.smtp_settings
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Rails.application.config.action_mailer.smtp_settings = nil fallback to ActionMailer::Base.smtp_settings" do
|
||||||
|
remove_from_config '.*config\.load_defaults.*\n'
|
||||||
|
add_to_config <<-RUBY
|
||||||
|
ActionMailer::Base.smtp_settings = { domain: "example.com" }
|
||||||
|
config.load_defaults "7.0"
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
app "development"
|
||||||
|
|
||||||
|
smtp_settings = { domain: "example.com", open_timeout: 5, read_timeout: 5 }
|
||||||
|
|
||||||
assert_equal smtp_settings, ActionMailer::Base.smtp_settings
|
assert_equal smtp_settings, ActionMailer::Base.smtp_settings
|
||||||
|
assert_nil Rails.configuration.action_mailer.smtp_settings
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Rails.application.config.action_mailer.smtp_settings = nil and ActionMailer::Base.smtp_settings = nil do not configure smtp_timeout" do
|
||||||
|
ActionMailer::Base.smtp_settings = nil
|
||||||
|
|
||||||
|
remove_from_config '.*config\.load_defaults.*\n'
|
||||||
|
add_to_config <<-RUBY
|
||||||
|
config.action_mailer.smtp_settings = nil
|
||||||
|
config.load_defaults "7.0"
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
app "development"
|
||||||
|
|
||||||
|
assert_nil Rails.configuration.action_mailer.smtp_settings
|
||||||
|
assert_nil ActionMailer::Base.smtp_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
test "ActiveSupport.utc_to_local_returns_utc_offset_times is true in 6.1 defaults" do
|
test "ActiveSupport.utc_to_local_returns_utc_offset_times is true in 6.1 defaults" do
|
||||||
|
|
Loading…
Reference in New Issue