Files
fizzy/saas/test/test_helpers/push_notification_test_helper.rb
T
Fernando Olivares 3c54cd84fc Add native push notification infrastructure
- Add action_push_native gem and SaaS configuration
- Add device registration API and UI
- Add User::Devices concern
- Add NotificationPusher::Native for push delivery
- Add tests and fixtures for native push
2026-02-25 19:31:13 +01:00

34 lines
1.1 KiB
Ruby

module PushNotificationTestHelper
# Assert native push notification is queued for delivery
def assert_native_push_delivery(count: 1, &block)
assert_enqueued_jobs count, only: ApplicationPushNotificationJob, &block
end
# Assert no native push notifications are queued
def assert_no_native_push_delivery(&block)
assert_native_push_delivery(count: 0, &block)
end
# Expect push notification to be delivered (using mocha)
def expect_native_push_delivery(count: 1)
ApplicationPushNotification.any_instance.expects(:deliver_later_to).times(count)
yield if block_given?
end
# Expect no push notification delivery
def expect_no_native_push_delivery(&block)
expect_native_push_delivery(count: 0, &block)
end
# Stub the push service to avoid actual API calls
def stub_push_services
ActionPushNative.stubs(:service_for).returns(stub(push: true))
end
# Stub push service to simulate token error (device should be deleted)
def stub_push_token_error
push_stub = stub.tap { |s| s.stubs(:push).raises(ActionPushNative::TokenError) }
ActionPushNative.stubs(:service_for).returns(push_stub)
end
end