Sha256: ccc4e7da3daf92880abc67ef7a0230c9e279060f39955e4aff89d82e6cb51729

Contents?: true

Size: 1.5 KB

Versions: 27

Compression:

Stored size: 1.5 KB

Contents

require 'rails_helper'

module PandaPal
  RSpec.describe Organization, type: :model do
    it 'creates a schema upon creation' do
      expect(Apartment::Tenant).to receive(:create)
      create :panda_pal_organization
    end

    it 'deletes a schema upon deletion' do
      expect(Apartment::Tenant).to receive(:create)
      expect(Apartment::Tenant).to receive(:drop)
      org = create :panda_pal_organization
      org.destroy
    end

    it 'does not allow the name to be changed after creation' do
      org = create :panda_pal_organization
      org.name = 'test123'
      expect(org.valid?).to be_falsey
    end

    it 'requires a salesforce_id' do
      org = build :panda_pal_organization, salesforce_id: nil
      expect(org.valid?).to be_falsey
    end

    it 'does not allow duplicate salesforce ids' do
      org = create :panda_pal_organization, salesforce_id: 'salesforce'
      org2 = build :panda_pal_organization, salesforce_id: 'salesforce'
      expect(org2.valid?).to be_falsey
    end

    it 'stores setting as an indifferent Hash' do
      org = create :panda_pal_organization
      org.update!(settings: { a: 1 })

      expect(Organization.last.settings).to be_a (ActiveSupport::HashWithIndifferentAccess)

      org.settings = {}
      expect(org.settings).to be_a (ActiveSupport::HashWithIndifferentAccess)
    end

    it 'stores settings' do
      org = create :panda_pal_organization
      org.update!(settings: { a: 1 })
      expect(Organization.last.settings[:a]).to eql(1)
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
panda_pal-5.12.7 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.6 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.5 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.4 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.3 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.2 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.1 spec/models/panda_pal/organization_spec.rb
panda_pal-5.12.0 spec/models/panda_pal/organization_spec.rb
panda_pal-5.11.0 spec/models/panda_pal/organization_spec.rb
panda_pal-5.10.1 spec/models/panda_pal/organization_spec.rb
panda_pal-5.10.0 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.8.beta1 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.7 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.6 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.5 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.4 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.3 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.1 spec/models/panda_pal/organization_spec.rb
panda_pal-5.9.0 spec/models/panda_pal/organization_spec.rb
panda_pal-5.8.5 spec/models/panda_pal/organization_spec.rb