Sha256: 80fe9ba8c3bbbc8b76d9476f45e55b96f477f9a3a23b62341fd9b02e570c8449
Contents?: true
Size: 1.65 KB
Versions: 28
Compression:
Stored size: 1.65 KB
Contents
require 'unit_spec_helper' require 'unit/notification_shared.rb' describe Rpush::Client::ActiveRecord::Adm::Notification do it_should_behave_like 'an Notification subclass' let(:app) { Rpush::Client::ActiveRecord::Adm::App.create!(name: 'test', client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET') } let(:notification_class) { Rpush::Client::ActiveRecord::Adm::Notification } let(:notification) { notification_class.new } it "has a 'data' payload limit of 6144 bytes" do notification.data = { key: "a" * 6144 } expect(notification.valid?).to eq(false) expect(notification.errors[:base]).to eq ["Notification payload data cannot be larger than 6144 bytes."] end it 'limits the number of registration ids to 100' do notification.registration_ids = ['a'] * (100 + 1) expect(notification.valid?).to eq(false) expect(notification.errors[:base]).to eq ["Number of registration_ids cannot be larger than 100."] end it 'validates data can be blank if collapse_key is set' do notification.app = app notification.registration_ids = 'a' notification.collapse_key = 'test' notification.data = nil expect(notification.valid?).to eq(true) expect(notification.errors[:data]).to be_empty end it 'validates data is present if collapse_key is not set' do notification.collapse_key = nil notification.data = nil expect(notification.valid?).to eq(false) expect(notification.errors[:data]).to eq ['must be set unless collapse_key is specified'] end it 'includes expiresAfter in the payload' do notification.expiry = 100 expect(notification.as_json['expiresAfter']).to eq 100 end end if active_record?
Version data entries
28 entries across 28 versions & 2 rubygems