Sha256: 23570913da59da0912a29dea02348750ad08dae6530de7c8a0d5fe957e7a1d57
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' module Plutus describe Account do describe 'tenancy support' do before(:all) do m = ActiveRecord::Migration.new m.verbose = false m.create_table :plutus_tenants do |t| t.string :name end end after :all do m = ActiveRecord::Migration.new m.verbose = false m.drop_table :plutus_tenants end before(:each) do ActiveSupportHelpers.clear_model('Account') ActiveSupportHelpers.clear_model('Asset') Plutus.enable_tenancy = true Plutus.tenant_class = 'Plutus::Tenant' FactoryGirlHelpers.reload() Plutus::Asset.new end after(:each) do if Plutus.const_defined?(:Asset) ActiveSupportHelpers.clear_model('Account') ActiveSupportHelpers.clear_model('Asset') end Plutus.enable_tenancy = false Plutus.tenant_class = nil FactoryGirlHelpers.reload() end it 'validate uniqueness of name scoped to tenant' do tenant = FactoryGirl.create(:tenant) account = FactoryGirl.create(:asset, tenant: tenant) record = FactoryGirl.build(:asset, name: account.name, tenant: tenant) expect(record).not_to be_valid expect(record.errors[:name]).to eq(['has already been taken']) end it 'allows same name scoped under a different tenant' do tenant_1 = FactoryGirl.create(:tenant) tenant_2 = FactoryGirl.create(:tenant) account = FactoryGirl.create(:asset, tenant: tenant_1) record = FactoryGirl.build(:asset, name: account.name, tenant: tenant_2) expect(record).to be_valid end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
plutus-0.17 | spec/models/tenancy_spec.rb |
plutus-0.16 | spec/models/tenancy_spec.rb |
plutus-0.15 | spec/models/tenancy_spec.rb |
plutus-0.14 | spec/models/tenancy_spec.rb |