Sha256: 9b196eeac1efdce364d99c211b6fa7333d145cfd5b801ec5fd2f937eba0e23d9

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require 'unit_spec_helper'
require 'unit/notification_shared.rb'

describe Rpush::Gcm::Notification do
  it_should_behave_like 'an Notification subclass'

  let(:app) { Rpush::Gcm::App.create!(:name => 'test', :auth_key => 'abc') }
  let(:notification_class) { Rpush::Gcm::Notification }
  let(:notification) { notification_class.new }
  let(:data_setter) { 'data=' }
  let(:data_getter) { 'data' }

  it "has a 'data' payload limit of 4096 bytes" do
    notification.data = { :key => "a" * 4096 }
    notification.valid?.should be_false
    notification.errors[:base].should eq ["Notification payload data cannot be larger than 4096 bytes."]
  end

  it 'limits the number of registration ids to 1000' do
    notification.registration_ids = ['a']*(1000+1)
    notification.valid?.should be_false
    notification.errors[:base].should eq ["Number of registration_ids cannot be larger than 1000."]
  end

  it 'validates expiry is present if collapse_key is set' do
    notification.collapse_key = 'test'
    notification.expiry = nil
    notification.valid?.should be_false
    notification.errors[:expiry].should eq ['must be set when using a collapse_key']
  end

  it 'includes time_to_live in the payload' do
    notification.expiry = 100
    notification.as_json['time_to_live'].should eq 100
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpush-1.0.0-java spec/unit/gcm/notification_spec.rb
rpush-1.0.0 spec/unit/gcm/notification_spec.rb