]> source.dussan.org Git - redmine.git/commitdiff
Fix sending mail with DeliveryJob is deprecated (#29914, #32908).
authorGo MAEDA <maeda@farend.jp>
Thu, 1 Apr 2021 14:41:03 +0000 (14:41 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 1 Apr 2021 14:41:03 +0000 (14:41 +0000)
Patch by Pavel Rosický.

git-svn-id: http://svn.redmine.org/redmine/trunk@20882 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mailer.rb
config/application.rb
lib/redmine/info.rb
test/unit/mailer_test.rb

index 1cea7c60fdecaabddf4736e1ae894a4df33156bf..f58a1c88df610148ceccf45f64cbf7363856e51c 100644 (file)
@@ -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)
index 29127891b5b713eeba43c45986b7f78781a3ad51..89d4fc1cab9314efc974b5ecad7db82ca4f245cb 100644 (file)
@@ -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)'
index a51deb2277d54fe32a37175d296943faa0281290..5aaab3e72563185836896a807363d78d5d7b0cbf 100644 (file)
@@ -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"
 
index 3f7aadf8e0d5e4aff2dcf80d2d2421704ea35459..f31a35015e487ee5c9320151d596a67a813b78fb 100644 (file)
@@ -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