Permalink
Browse files

Bug fix to performance tweak.

  • Loading branch information...
1 parent ecec88a commit bd82e69b4e470c111df8ee2532b8296800be8893 @ErwinM committed Jan 7, 2014
View
@@ -1,3 +1,7 @@
+0.3.4
+-----
+* Fix to a bug introduced in 0.3.2
+
0.3.3
-----
* Support user defined foreign keys on scoped models
@@ -95,7 +95,7 @@ def acts_as_tenant(tenant = :account, options = {})
end
define_method "#{ActsAsTenant.tenant_klass.to_s}" do
- return ActsAsTenant.current_tenant if send(fkey) == ActsAsTenant.current_tenant.id
+ return ActsAsTenant.current_tenant if send(fkey) == ActsAsTenant.current_tenant.try(:id)
super()
end
@@ -1,3 +1,3 @@
module ActsAsTenant
- VERSION = "0.3.3"
+ VERSION = "0.3.4"
end
@@ -174,6 +174,24 @@ class CustomForeignKeyTask < ActiveRecord::Base
it { @projects.count.should == 2 }
end
+ describe 'Querying the tenant from a scoped model without a tenant set' do
+ before do
+ @project = Project.create!(:name => 'bar')
+ end
+
+ it { @project.account }
+ end
+
+ describe 'Querying the tenant from a scoped model with a tenant set' do
+ before do
+ @account = Account.create!(:name => 'foo')
+ @project = @account.projects.create!(:name => 'foobar')
+ ActsAsTenant.current_tenant= @account1
+ end
+
+ it { @project.account }
+ end
+
# Associations
describe 'Associations should be correctly scoped by current tenant' do
before do

0 comments on commit bd82e69

Please sign in to comment.