From: Go MAEDA Date: Thu, 1 Apr 2021 14:41:03 +0000 (+0000) Subject: Fix sending mail with DeliveryJob is deprecated (#29914, #32908). X-Git-Tag: 5.0.0~477 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ba6ace46d755fa5f26fe590d9e086bb762df4652;p=redmine.git Fix sending mail with DeliveryJob is deprecated (#29914, #32908). Patch by Pavel Rosický. git-svn-id: http://svn.redmine.org/redmine/trunk@20882 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 1cea7c60f..f58a1c88d 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -642,13 +642,13 @@ class Mailer < ActionMailer::Base # Rake will likely end, causing the in-process thread pool to be deleted, before # any/all of the .deliver_later emails are processed def self.with_synched_deliveries(&block) - adapter = ActionMailer::DeliveryJob.queue_adapter + adapter = ActionMailer::MailDeliveryJob.queue_adapter if adapter.is_a?(ActiveJob::QueueAdapters::AsyncAdapter) - ActionMailer::DeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new + ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new end yield ensure - ActionMailer::DeliveryJob.queue_adapter = adapter + ActionMailer::MailDeliveryJob.queue_adapter = adapter end def mail(headers={}, &block) diff --git a/config/application.rb b/config/application.rb index 29127891b..89d4fc1ca 100644 --- a/config/application.rb +++ b/config/application.rb @@ -33,6 +33,8 @@ module RedmineApp config.active_record.store_full_sti_class = true config.active_record.default_timezone = :local + config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' diff --git a/lib/redmine/info.rb b/lib/redmine/info.rb index a51deb227..5aaab3e72 100644 --- a/lib/redmine/info.rb +++ b/lib/redmine/info.rb @@ -16,7 +16,7 @@ module Redmine ["Rails version", Rails::VERSION::STRING], ["Environment", Rails.env], ["Database adapter", ActiveRecord::Base.connection.adapter_name], - ["Mailer queue", ActionMailer::DeliveryJob.queue_adapter.class.name], + ["Mailer queue", ActionMailer::MailDeliveryJob.queue_adapter.class.name], ["Mailer delivery", ActionMailer::Base.delivery_method] ].map {|info| " %-30s %s" % info}.join("\n") + "\n" diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 3f7aadf8e..f31a35015 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -1064,14 +1064,14 @@ class MailerTest < ActiveSupport::TestCase end def test_with_synched_deliveries_should_yield_with_synced_deliveries - ActionMailer::DeliveryJob.queue_adapter = ActiveJob::QueueAdapters::AsyncAdapter.new + ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::AsyncAdapter.new Mailer.with_synched_deliveries do - assert_kind_of ActiveJob::QueueAdapters::InlineAdapter, ActionMailer::DeliveryJob.queue_adapter + assert_kind_of ActiveJob::QueueAdapters::InlineAdapter, ActionMailer::MailDeliveryJob.queue_adapter end - assert_kind_of ActiveJob::QueueAdapters::AsyncAdapter, ActionMailer::DeliveryJob.queue_adapter + assert_kind_of ActiveJob::QueueAdapters::AsyncAdapter, ActionMailer::MailDeliveryJob.queue_adapter ensure - ActionMailer::DeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new + ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new end def test_email_addresses_should_keep_addresses