Project

General

Profile

Defect #32908 » maildeliveryjob.patch

Pavel Rosický, 2020-01-28 22:55

View differences:

app/models/mailer.rb (working copy)
624 624
  # Rake will likely end, causing the in-process thread pool to be deleted, before
625 625
  # any/all of the .deliver_later emails are processed
626 626
  def self.with_synched_deliveries(&block)
627
    adapter = ActionMailer::DeliveryJob.queue_adapter
627
    adapter = ActionMailer::MailDeliveryJob.queue_adapter
628 628
    if adapter.is_a?(ActiveJob::QueueAdapters::AsyncAdapter)
629
      ActionMailer::DeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new
629
      ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new
630 630
    end
631 631
    yield
632 632
  ensure
633
    ActionMailer::DeliveryJob.queue_adapter = adapter
633
    ActionMailer::MailDeliveryJob.queue_adapter = adapter
634 634
  end
635 635

  
636 636
  def mail(headers={}, &block)
config/application.rb (working copy)
33 33
    config.active_record.store_full_sti_class = true
34 34
    config.active_record.default_timezone = :local
35 35

  
36
    config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
37

  
36 38
    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
37 39
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
38 40
    # config.time_zone = 'Central Time (US & Canada)'
lib/redmine/info.rb (working copy)
16 16
          ["Rails version", Rails::VERSION::STRING],
17 17
          ["Environment", Rails.env],
18 18
          ["Database adapter", ActiveRecord::Base.connection.adapter_name],
19
          ["Mailer queue", ActionMailer::DeliveryJob.queue_adapter.class.name],
19
          ["Mailer queue", ActionMailer::MailDeliveryJob.queue_adapter.class.name],
20 20
          ["Mailer delivery", ActionMailer::Base.delivery_method]
21 21
        ].map {|info| "  %-30s %s" % info}.join("\n") + "\n"
22 22

  
test/unit/mailer_test.rb (working copy)
968 968
  end
969 969

  
970 970
  def test_with_synched_deliveries_should_yield_with_synced_deliveries
971
    ActionMailer::DeliveryJob.queue_adapter = ActiveJob::QueueAdapters::AsyncAdapter.new
971
    ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::AsyncAdapter.new
972 972

  
973 973
    Mailer.with_synched_deliveries do
974
      assert_kind_of ActiveJob::QueueAdapters::InlineAdapter, ActionMailer::DeliveryJob.queue_adapter
974
      assert_kind_of ActiveJob::QueueAdapters::InlineAdapter, ActionMailer::MailDeliveryJob.queue_adapter
975 975
    end
976
    assert_kind_of ActiveJob::QueueAdapters::AsyncAdapter, ActionMailer::DeliveryJob.queue_adapter
976
    assert_kind_of ActiveJob::QueueAdapters::AsyncAdapter, ActionMailer::MailDeliveryJob.queue_adapter
977 977
  ensure
978
    ActionMailer::DeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new
978
    ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new
979 979
  end
980 980

  
981 981
  def test_email_addresses_should_keep_addresses
    (1-1/1)