chore: Add climate-control gem for handling the test ENV vars (#3267)
This commit is contained in:
@@ -14,26 +14,23 @@ describe Notification::PushNotificationService do
|
||||
|
||||
describe '#perform' do
|
||||
it 'sends webpush notifications for webpush subscription' do
|
||||
ENV['VAPID_PUBLIC_KEY'] = 'test'
|
||||
create(:notification_subscription, user: notification.user)
|
||||
with_modified_env VAPID_PUBLIC_KEY: 'test' do
|
||||
create(:notification_subscription, user: notification.user)
|
||||
|
||||
described_class.new(notification: notification).perform
|
||||
expect(Webpush).to have_received(:payload_send)
|
||||
expect(FCM).not_to have_received(:new)
|
||||
ENV['VAPID_PUBLIC_KEY'] = nil
|
||||
described_class.new(notification: notification).perform
|
||||
expect(Webpush).to have_received(:payload_send)
|
||||
expect(FCM).not_to have_received(:new)
|
||||
end
|
||||
end
|
||||
|
||||
it 'sends a fcm notification for firebase subscription' do
|
||||
ENV['FCM_SERVER_KEY'] = 'test'
|
||||
ENV['ENABLE_PUSH_RELAY_SERVER'] = 'false'
|
||||
create(:notification_subscription, user: notification.user, subscription_type: 'fcm')
|
||||
with_modified_env FCM_SERVER_KEY: 'test', ENABLE_PUSH_RELAY_SERVER: 'false' do
|
||||
create(:notification_subscription, user: notification.user, subscription_type: 'fcm')
|
||||
|
||||
described_class.new(notification: notification).perform
|
||||
expect(FCM).to have_received(:new)
|
||||
expect(Webpush).not_to have_received(:payload_send)
|
||||
|
||||
ENV['FCM_SERVER_KEY'] = nil
|
||||
ENV['ENABLE_PUSH_RELAY_SERVER'] = nil
|
||||
described_class.new(notification: notification).perform
|
||||
expect(FCM).to have_received(:new)
|
||||
expect(Webpush).not_to have_received(:payload_send)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user