Sha256: 745df000f3f58f531f363ddc1094120f518cc63bf0ad537a375dae49ae264a9e

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

require "unit_spec_helper"

describe Rpush::Client::ActiveRecord::Apnsp8::Notification do
  subject(:notification) { described_class.new }

  it_behaves_like 'Rpush::Client::Apns::Notification'
  it_behaves_like 'Rpush::Client::ActiveRecord::Notification'

  it "should validate the length of the binary conversion of the notification", :aggregate_failures do
    notification = described_class.new
    notification.app = Rpush::Apnsp8::App.create(apn_key: "1",
                                                 apn_key_id: "2",
                                                 name: 'test',
                                                 environment: 'development',
                                                 team_id: "3",
                                                 bundle_id: "4")
    notification.device_token = "a" * 108
    notification.alert = ""

    notification.alert << "a" until notification.payload.bytesize == 4096
    expect(notification.valid?).to be_truthy
    expect(notification.errors[:base]).to be_empty

    notification.alert << "a"
    expect(notification.valid?).to be_falsey
    expect(notification.errors[:base].include?("APN notification cannot be larger than 4096 bytes. Try condensing your alert and device attributes.")).to be_truthy
  end
end if active_record?

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rpush-9.1.0 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-9.0.0 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-8.0.0 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-7.0.1 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-7.0.0 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-6.0.1 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-6.0.0 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-5.4.0 spec/unit/client/active_record/apnsp8/notification_spec.rb
rpush-5.3.0 spec/unit/client/active_record/apnsp8/notification_spec.rb