Skip to content

Commit

Permalink
Monkey patch MailDeliveryJob to work with delayed_job under ruby 3
Browse files Browse the repository at this point in the history
The delayed_job gem does not currently perserve keyword arguments
properly leading to errors when running under ruby 3 and try to run
a job that requires them.

This affects our deferred mail deliveries so we monkey patch the
mail delivery job to unpack the hash from the normal arguments and
use it to provide the expected keyword arguments.

collectiveidea/delayed_job#1134
  • Loading branch information
tomhughes committed Jul 23, 2022
1 parent 273cb9e commit 21d52f2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/initializers/mail_delivery_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module OpenStreetMap
module ActionMailer
module MailDeliveryJob
def perform(mailer, mail_method, delivery_method, *args, **kwargs)
kwargs = args.pop if kwargs.empty? && args.last.is_a?(Hash)

super(mailer, mail_method, delivery_method, *args, **kwargs)
end
end
end
end

ActionMailer::MailDeliveryJob.prepend(OpenStreetMap::ActionMailer::MailDeliveryJob)

0 comments on commit 21d52f2

Please sign in to comment.