Rename push to process on PushTarget for clearer semantics

"Push to target" reads naturally - we push the notification to the
target. "Target processes" also makes sense - the target receives
and handles the notification in its own way.

- Add class method PushTarget.process(notification) that instantiates
  and calls the instance method
- Rename instance method from push to process
- Add private push_to helper in Pushable for readable iteration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-01-22 18:02:25 +01:00
parent 3621df8f0f
commit 0948533da7
5 changed files with 27 additions and 23 deletions
@@ -27,28 +27,28 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
subscriptions.count == 1
end
Notification::PushTarget::Web.new(@notification).push
Notification::PushTarget::Web.new(@notification).process
end
test "does not push when user has no subscriptions" do
@user.push_subscriptions.delete_all
@web_push_pool.expects(:queue).never
Notification::PushTarget::Web.new(@notification).push
Notification::PushTarget::Web.new(@notification).process
end
test "does not push for cancelled accounts" do
@user.account.cancel(initiated_by: @user)
@web_push_pool.expects(:queue).never
Notification::PushTarget::Web.new(@notification).push
Notification::PushTarget::Web.new(@notification).process
end
test "does not push when creator is system user" do
@notification.update!(creator: users(:system))
@web_push_pool.expects(:queue).never
Notification::PushTarget::Web.new(@notification).push
Notification::PushTarget::Web.new(@notification).process
end
test "payload includes card title for card events" do
@@ -56,7 +56,7 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
payload[:title] == @notification.card.title
end
Notification::PushTarget::Web.new(@notification).push
Notification::PushTarget::Web.new(@notification).process
end
test "payload for comment includes RE prefix" do
@@ -67,7 +67,7 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
payload[:title].start_with?("RE:")
end
Notification::PushTarget::Web.new(notification).push
Notification::PushTarget::Web.new(notification).process
end
test "payload for assignment includes assigned message" do
@@ -78,7 +78,7 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
payload[:body].include?("Assigned to you")
end
Notification::PushTarget::Web.new(notification).push
Notification::PushTarget::Web.new(notification).process
end
test "payload for mention includes mentioner name" do
@@ -89,7 +89,7 @@ class Notification::PushTarget::WebTest < ActiveSupport::TestCase
payload[:title].include?("mentioned you")
end
Notification::PushTarget::Web.new(notification).push
Notification::PushTarget::Web.new(notification).process
end
end
+2 -5
View File
@@ -15,12 +15,9 @@ class Notification::PushableTest < ActiveSupport::TestCase
end
end
test "push calls push on all registered targets" do
test "push calls process 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)
target_class.expects(:process).with(@notification)
original_targets = Notification.push_targets
Notification.push_targets = [ target_class ]