acts_as_tenant 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/acts_as_tenant/model_extensions.rb +3 -1
- data/lib/acts_as_tenant/version.rb +1 -1
- data/spec/model_extensions_spec.rb +5 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -74,7 +74,9 @@ module ActsAsTenant
|
|
74
74
|
# find the unaliased class name
|
75
75
|
association_class = a.options[:class_name].nil? ? a.name.to_s.classify.constantize : a.options[:class_name].constantize
|
76
76
|
validates_each a.foreign_key.to_sym do |record, attr, value|
|
77
|
-
|
77
|
+
# Invalidate the association unless the parent is known to the tenant or no association has
|
78
|
+
# been set.
|
79
|
+
record.errors.add attr, "is invalid" unless association_class.where(:id => value).present? || value.nil?
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -215,4 +215,9 @@ describe ActsAsTenant do
|
|
215
215
|
it { @sub_task = SubTask.create(:name => 'foo').valid?.should == true }
|
216
216
|
end
|
217
217
|
|
218
|
+
describe "It should be possible to create and save an AaT-enabled child without it having a parent" do
|
219
|
+
@account = Account.create!(:name => 'baz')
|
220
|
+
ActsAsTenant.current_tenant = @account
|
221
|
+
Task.create(:name => 'bar').valid?.should == true
|
222
|
+
end
|
218
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_tenant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-08 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Integrates multi-tenancy into a Rails application in a convenient and
|
15
15
|
out-of-your way manner
|