Sha256: 243d46139e94a70fea25e777171ecc7f9d650e699281007a5163b77668005195

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require 'unit_spec_helper'

describe Rpush::Daemon::Delivery do

  class DeliverySpecDelivery < Rpush::Daemon::Delivery
    def initialize(batch)
      @batch = batch
    end
  end

  let(:now) { Time.parse("2014-10-14 00:00:00") }
  let(:batch) { double(Rpush::Daemon::Batch) }
  let(:delivery) { DeliverySpecDelivery.new(batch) }
  let(:notification) { Rpush::Apns::Notification.new }

  before { Time.stub(now: now) }

  describe 'mark_retryable' do

    it 'does not retry a notification with an expired fail_after' do
      batch.should_receive(:mark_failed).with(notification, nil, "Notification failed to be delivered before 2014-10-13 23:00:00.")
      notification.fail_after = Time.now - 1.hour
      delivery.mark_retryable(notification, Time.now + 1.hour)
    end

    it 'retries the notification if does not have a fail_after time' do
      batch.should_receive(:mark_retryable)
      notification.fail_after = nil
      delivery.mark_retryable(notification, Time.now + 1.hour)
    end

    it 'retries the notification if the fail_after time has not been reached' do
      batch.should_receive(:mark_retryable)
      notification.fail_after = Time.now + 1.hour
      delivery.mark_retryable(notification, Time.now + 1.hour)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpush-1.0.0-java spec/unit/daemon/delivery_spec.rb
rpush-1.0.0 spec/unit/daemon/delivery_spec.rb