Skip to content

Commit 1b6b3f4

Browse files
committed
Flag push_notifications as processed
1 parent dce49e0 commit 1b6b3f4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

app/services/push_notifications/broadcast.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def send
99

1010
client = Exponent::Push::Client.new
1111

12+
push_notifications.update_all(processed_at: Time.now.utc)
1213
client.publish(notifications)
1314
end
1415

spec/services/push_notifications/broadcast_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
title: 'Hola'
1515
)
1616
end
17+
let(:push_notifications) { PushNotification.all }
1718
let(:client) { instance_double(Exponent::Push::Client) }
1819
let(:notification) do
1920
{
@@ -26,7 +27,16 @@
2627
expect(Exponent::Push::Client).to receive(:new).and_return(client)
2728
expect(client).to receive(:publish).with([notification])
2829

29-
described_class.new(push_notifications: [push_notification]).send
30+
described_class.new(push_notifications: push_notifications).send
31+
end
32+
33+
it 'flags the push_notification as processed' do
34+
allow(Exponent::Push::Client).to receive(:new).and_return(client)
35+
allow(client).to receive(:publish).with([notification])
36+
37+
described_class.new(push_notifications: push_notifications).send
38+
39+
expect(push_notification.reload.processed_at).to_not be_nil
3040
end
3141
end
3242
end

0 commit comments

Comments
 (0)