Skip to content

Commit

Permalink
Flag push_notifications as processed
Browse files Browse the repository at this point in the history
  • Loading branch information
enricostano committed Jun 19, 2018
1 parent 1df2176 commit ed4b3a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/services/push_notifications/broadcast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def send

client = Exponent::Push::Client.new

push_notifications.update_all(processed_at: Time.now.utc)
client.publish(notifications)
end

Expand Down
12 changes: 11 additions & 1 deletion spec/services/push_notifications/broadcast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
title: 'Hola'
)
end
let(:push_notifications) { PushNotification.all }
let(:client) { instance_double(Exponent::Push::Client) }
let(:notification) do
{
Expand All @@ -26,7 +27,16 @@
expect(Exponent::Push::Client).to receive(:new).and_return(client)
expect(client).to receive(:publish).with([notification])

described_class.new(push_notifications: [push_notification]).send
described_class.new(push_notifications: push_notifications).send
end

it 'flags the push_notification as processed' do
allow(Exponent::Push::Client).to receive(:new).and_return(client)
allow(client).to receive(:publish).with([notification])

described_class.new(push_notifications: push_notifications).send

expect(push_notification.reload.processed_at).to_not be_nil
end
end
end

0 comments on commit ed4b3a5

Please # to comment.