Add method for delivery job

This commit is contained in:
Jorge Manrubia
2025-08-27 15:48:27 +02:00
parent 0a32cfd611
commit ccceeb1699
2 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -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
+18
View File
@@ -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