Consolidate push jobs into single Notification::PushJob

Replace separate WebPushJob and NativePushJob with a single PushJob
that calls notification.push, which iterates over registered targets.
Each target handles its own delivery - Web pushes synchronously via
the pool, Native enqueues device-level jobs via deliver_later_to.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-01-22 17:19:21 +01:00
parent 4f19c42958
commit 3621df8f0f
9 changed files with 24 additions and 34 deletions
@@ -92,9 +92,4 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
Notification::PushTarget::Web.new(notification).push
end
test "push_later enqueues Notification::WebPushJob" do
assert_enqueued_with(job: Notification::WebPushJob, args: [ @notification ]) do
Notification::PushTarget::Web.push_later(@notification)
end
end
end
+14 -5
View File
@@ -9,14 +9,23 @@ class Notification::PushableTest < ActiveSupport::TestCase
)
end
test "push_later calls push_later on all registered targets" do
target = mock("push_target")
target.expects(:push_later).with(@notification)
test "push_later enqueues Notification::PushJob" do
assert_enqueued_with(job: Notification::PushJob, args: [ @notification ]) do
@notification.push_later
end
end
test "push calls push on all registered targets" do
target_class = mock("push_target_class")
target_instance = mock("push_target_instance")
target_class.expects(:new).with(@notification).returns(target_instance)
target_instance.expects(:push)
original_targets = Notification.push_targets
Notification.push_targets = [ target ]
Notification.push_targets = [ target_class ]
@notification.push_later
@notification.push
ensure
Notification.push_targets = original_targets
end