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 CHANGED
@@ -1,3 +1,8 @@
1
+ 0.2.4
2
+ -----
3
+ * Added correct handling of child models that do not have their parent set (foreign key == nil)
4
+
5
+
1
6
  0.2.3
2
7
  -----
3
8
  * Added support for models that declare a has_one relationships, these would error out in the previous versions.
@@ -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
- record.errors.add attr, "is invalid" unless association_class.where(:id => value).present?
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
@@ -1,3 +1,3 @@
1
1
  module ActsAsTenant
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  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.3
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-11-20 00:00:00.000000000Z
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