Sha256: 76eb4feead73956781812a834207ee7380400a313770e080af34f9a915cac966
Contents?: true
Size: 1.3 KB
Versions: 12
Compression:
Stored size: 1.3 KB
Contents
require 'functional_spec_helper' describe 'Retries' do let(:app) { Rpush::Gcm::App.new } let(:notification) { Rpush::Gcm::Notification.new } let(:response) { double(Net::HTTPResponse, code: 200) } let(:http) { double(Net::HTTP::Persistent, request: response, shutdown: nil) } before do Rpush::Daemon.initialize_store app.name = 'test' app.auth_key = 'abc123' app.save! notification.app_id = app.id notification.registration_ids = ['foo'] notification.data = { message: 'test' } notification.save! Modis.with_connection do |redis| redis.del(Rpush::Client::Redis::Notification.absolute_pending_namespace) end Net::HTTP::Persistent.stub(new: http) response.stub(body: JSON.dump(results: [{ message_id: notification.registration_ids.first.to_s }])) end it 'delivers a notification due to be retried' do Rpush::Daemon.store.mark_retryable(notification, Time.now - 1.minute) expect do Rpush.push notification.reload end.to change(notification, :delivered).to(true) end it 'does not deliver a notification not due to be retried' do Rpush::Daemon.store.mark_retryable(notification, Time.now + 1.minute) expect do Rpush.push notification.reload end.to_not change(notification, :delivered).to(true) end end
Version data entries
12 entries across 12 versions & 1 rubygems