Sha256: 1b724a3002c62497a61f145e1ab0791353775b79d45a2ac908171ca0cfd7f7be

Contents?: true

Size: 1.34 KB

Versions: 17

Compression:

Stored size: 1.34 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)
    app.valid?.should be_false
    app.errors[:name].should eq ['has already been taken']

    app = Rpush::Client::ActiveRecord::Apns::App.new(name: 'test', environment: 'development', certificate: TEST_CERT)
    app.valid?.should be_true

    app = Rpush::Client::ActiveRecord::Gcm::App.new(name: 'test', environment: 'production', auth_key: TEST_CERT)
    app.valid?.should be_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 be_false
    end

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rpush-2.3.1-java spec/unit/client/active_record/app_spec.rb
rpush-2.3.1 spec/unit/client/active_record/app_spec.rb
rpush-2.3.0-java spec/unit/client/active_record/app_spec.rb
rpush-2.3.0 spec/unit/client/active_record/app_spec.rb
rpush-2.3.0.rc1 spec/unit/client/active_record/app_spec.rb
rpush-2.2.0-java spec/unit/client/active_record/app_spec.rb
rpush-2.2.0 spec/unit/client/active_record/app_spec.rb
rpush-2.1.0-java spec/unit/client/active_record/app_spec.rb
rpush-2.1.0 spec/unit/client/active_record/app_spec.rb
rpush-2.0.1-java spec/unit/client/active_record/app_spec.rb
rpush-2.0.1 spec/unit/client/active_record/app_spec.rb
rpush-2.0.0-java spec/unit/client/active_record/app_spec.rb
rpush-2.0.0 spec/unit/client/active_record/app_spec.rb
rpush-2.0.0.rc1-java spec/unit/client/active_record/app_spec.rb
rpush-2.0.0.rc1 spec/unit/client/active_record/app_spec.rb
rpush-2.0.0.beta2 spec/unit/client/active_record/app_spec.rb
rpush-2.0.0.beta1 spec/unit/client/active_record/app_spec.rb