diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/parameterized.rb | 10 | ||||
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 2 | ||||
-rw-r--r-- | actionmailer/test/legacy_delivery_job_test.rb | 7 |
3 files changed, 13 insertions, 6 deletions
diff --git a/actionmailer/lib/action_mailer/parameterized.rb b/actionmailer/lib/action_mailer/parameterized.rb index 999435919e..0a97af8105 100644 --- a/actionmailer/lib/action_mailer/parameterized.rb +++ b/actionmailer/lib/action_mailer/parameterized.rb @@ -145,12 +145,20 @@ module ActionMailer if processed? super else - job = @mailer_class.delivery_job + job = delivery_job_class args = arguments_for(job, delivery_method) job.set(options).perform_later(*args) end end + def delivery_job_class + if @mailer_class.delivery_job <= MailDeliveryJob + @mailer_class.delivery_job + else + Parameterized::DeliveryJob + end + end + def arguments_for(delivery_job, delivery_method) if delivery_job <= MailDeliveryJob [@mailer_class.name, @action.to_s, delivery_method.to_s, params: @params, args: @args] diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index f647896374..448807c144 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -33,6 +33,8 @@ I18n.enforce_available_locales = false FIXTURE_LOAD_PATH = File.expand_path("fixtures", __dir__) ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH +ActionMailer::Base.delivery_job = ActionMailer::MailDeliveryJob + class ActiveSupport::TestCase include ActiveSupport::Testing::MethodCallAssertions diff --git a/actionmailer/test/legacy_delivery_job_test.rb b/actionmailer/test/legacy_delivery_job_test.rb index 112c842beb..3a3872df47 100644 --- a/actionmailer/test/legacy_delivery_job_test.rb +++ b/actionmailer/test/legacy_delivery_job_test.rb @@ -11,9 +11,6 @@ class LegacyDeliveryJobTest < ActiveSupport::TestCase class LegacyDeliveryJob < ActionMailer::DeliveryJob end - class LegacyParmeterizedDeliveryJob < ActionMailer::Parameterized::DeliveryJob - end - setup do @previous_logger = ActiveJob::Base.logger ActiveJob::Base.logger = Logger.new(nil) @@ -42,9 +39,9 @@ class LegacyDeliveryJobTest < ActiveSupport::TestCase { inviter: "david@basecamp.com", invitee: "jason@basecamp.com" }, ] - with_delivery_job(LegacyParmeterizedDeliveryJob) do + with_delivery_job(LegacyDeliveryJob) do assert_deprecated do - assert_performed_with(job: LegacyParmeterizedDeliveryJob, args: args) do + assert_performed_with(job: ActionMailer::Parameterized::DeliveryJob, args: args) do mail.deliver_later end end |