diff --git a/app/models/notification/bundle.rb b/app/models/notification/bundle.rb index 98c2d131b..78d4b5dd8 100644 --- a/app/models/notification/bundle.rb +++ b/app/models/notification/bundle.rb @@ -21,7 +21,8 @@ class Notification::Bundle < ApplicationRecord class << self def deliver_all due.in_batches do |batch| - DeliverJob.perform_all_later batch + jobs = batch.collect { DeliverJob.new(it) } + ActiveJob.perform_all_later jobs end end diff --git a/test/models/notification/bundle_test.rb b/test/models/notification/bundle_test.rb index f9bf4abca..1149ae174 100644 --- a/test/models/notification/bundle_test.rb +++ b/test/models/notification/bundle_test.rb @@ -73,4 +73,22 @@ class Notification::BundleTest < ActiveSupport::TestCase ) assert bundle_5.valid? end + + test "deliver_all delivers due bundles" do + notification = @user.notifications.create!(source: events(:logo_published), creator: @user) + + bundle = @user.notification_bundles.pending.last + + assert bundle.pending? + assert_includes bundle.notifications, notification + + bundle.update!(ends_at: 1.minute.ago) + + perform_enqueued_jobs do + Notification::Bundle.deliver_all + end + + bundle.reload + assert bundle.delivered? + end end