Sha256: 06a96320678dc5bd26fdf21481697ae87b53c8649d49ec154c0093b466c3e078

Contents?: true

Size: 1.39 KB

Versions: 28

Compression:

Stored size: 1.39 KB

Contents

require 'unit_spec_helper'

describe Rpush::Client::ActiveRecord::App do
  it 'validates the uniqueness of name within type and environment' do
    Rpush::Client::ActiveRecord::Apns::App.create!(name: 'test', environment: 'production', certificate: TEST_CERT)
    app = Rpush::Client::ActiveRecord::Apns::App.new(name: 'test', environment: 'production', certificate: TEST_CERT)
    expect(app.valid?).to eq(false)
    expect(app.errors[:name]).to eq ['has already been taken']

    app = Rpush::Client::ActiveRecord::Apns::App.new(name: 'test', environment: 'development', certificate: TEST_CERT)
    expect(app.valid?).to eq(true)

    app = Rpush::Client::ActiveRecord::Gcm::App.new(name: 'test', environment: 'production', auth_key: TEST_CERT)
    expect(app.valid?).to eq(true)
  end

  context 'validating certificates' do
    it 'rescues from certificate error' do
      app = Rpush::Client::ActiveRecord::Apns::App.new(name: 'test', environment: 'development', certificate: 'bad')
      expect { app.valid? }.not_to raise_error
      expect(app.valid?).to eq(false)
    end

    it 'raises other errors' do
      app = Rpush::Client::ActiveRecord::Apns::App.new(name: 'test', environment: 'development', certificate: 'bad')
      allow(OpenSSL::X509::Certificate).to receive(:new).and_raise(NameError, 'simulating no openssl')
      expect { app.valid? }.to raise_error(NameError)
    end
  end
end if active_record?

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
rpush-5.0.0 spec/unit/client/active_record/app_spec.rb
rpush-4.2.0 spec/unit/client/active_record/app_spec.rb
rpush-4.1.1 spec/unit/client/active_record/app_spec.rb
rpush-4.1.0 spec/unit/client/active_record/app_spec.rb
rpush-4.0.1 spec/unit/client/active_record/app_spec.rb
rpush-4.0.0 spec/unit/client/active_record/app_spec.rb
rpush-3.3.1 spec/unit/client/active_record/app_spec.rb
rpush-3.3.0 spec/unit/client/active_record/app_spec.rb
rpush_extended-3.2.6 spec/unit/client/active_record/app_spec.rb
rpush_extended-3.2.5 spec/unit/client/active_record/app_spec.rb
rpush-3.2.4 spec/unit/client/active_record/app_spec.rb
rpush-3.2.3 spec/unit/client/active_record/app_spec.rb
rpush-3.2.2 spec/unit/client/active_record/app_spec.rb
rpush-3.2.1 spec/unit/client/active_record/app_spec.rb
rpush-3.2.0 spec/unit/client/active_record/app_spec.rb
rpush-3.1.1 spec/unit/client/active_record/app_spec.rb
rpush-3.1.0 spec/unit/client/active_record/app_spec.rb
rpush-3.0.2 spec/unit/client/active_record/app_spec.rb
rpush-3.0.1 spec/unit/client/active_record/app_spec.rb
rpush-3.0.0 spec/unit/client/active_record/app_spec.rb