Skip to content
Extraits de code Groupes Projets
Valider 83ccdeb8 rédigé par Eugen Rochko's avatar Eugen Rochko
Parcourir les fichiers

Fix tests

parent 3f075c77
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,13 +2,13 @@
class SendPushNotificationService < BaseService
def call(notification)
return if ENV['FCM_API_KEY'].blank?
return if ENV['FCM_API_KEY'].blank?
devices = Device.where(account: notification.account).pluck(:registration_id)
fcm = FCM.new(ENV['FCM_API_KEY'])
devices = Device.where(account: notification.account).pluck(:registration_id)
fcm = FCM.new(ENV['FCM_API_KEY'])
response = fcm.send(devices, data: { notification_id: notification.id }, collapse_key: :notifications, priority: :high)
handle_response(response)
response = fcm.send(devices, data: { notification_id: notification.id }, collapse_key: :notifications, priority: :high)
handle_response(response)
end
private
......@@ -19,10 +19,10 @@ class SendPushNotificationService < BaseService
end
def update_canonical_ids(ids)
ids.each { |pair| Device.find_by(registration_id: pair[:old]).update(registration_id: pair[:new]) }
ids.each { |pair| Device.find_by(registration_id: pair[:old]).update(registration_id: pair[:new]) }
end
def remove_bad_ids(bad_ids)
Device.where(registration_id: bad_ids).delete_all
Device.where(registration_id: bad_ids).delete_all unless bad_ids.empty?
end
end
......@@ -13,7 +13,11 @@ RSpec.configure do |config|
mocks.verify_partial_doubles = true
end
config.after(:suite) do
config.before :each do
stub_request(:post, 'https://fcm.googleapis.com/fcm/send').to_return(status: 200, body: '')
end
config.after :suite do
FileUtils.rm_rf(Dir["#{Rails.root}/spec/test_files/"])
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter