acts_as_tenant 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ 0.2.3
2
+ -----
3
+ * Added support for models that declare a has_one relationships, these would error out in the previous versions.
4
+
5
+
1
6
  0.2.2
2
7
  -----
3
8
  * Enhancements
@@ -69,7 +69,7 @@ module ActsAsTenant
69
69
  # we can't do this for polymorphic associations so we
70
70
  # exempt them
71
71
  reflect_on_all_associations.each do |a|
72
- unless a == reflection || a.macro == :has_many || a.options[:polymorphic]
72
+ unless a == reflection || a.macro == :has_many || a.macro == :has_one || a.options[:polymorphic]
73
73
  # check if the association is aliasing another class, if so
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
@@ -1,3 +1,3 @@
1
1
  module ActsAsTenant
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -11,6 +11,12 @@ ActiveRecord::Schema.define(:version => 1) do
11
11
  t.column :account_id, :integer
12
12
  end
13
13
 
14
+ create_table :managers, :force => true do |t|
15
+ t.column :name, :string
16
+ t.column :project_id, :integer
17
+ t.column :account_id, :integer
18
+ end
19
+
14
20
  create_table :tasks, :force => true do |t|
15
21
  t.column :name, :string
16
22
  t.column :account_id, :integer
@@ -39,12 +45,18 @@ class Account < ActiveRecord::Base
39
45
  end
40
46
 
41
47
  class Project < ActiveRecord::Base
48
+ has_one :manager
42
49
  has_many :tasks
43
50
  acts_as_tenant :account
44
51
 
45
52
  validates_uniqueness_to_tenant :name
46
53
  end
47
54
 
55
+ class Manager < ActiveRecord::Base
56
+ belongs_to :project
57
+ acts_as_tenant :account
58
+ end
59
+
48
60
  class Task < ActiveRecord::Base
49
61
  belongs_to :project
50
62
  default_scope :conditions => { :completed => nil }, :order => "name"
@@ -58,6 +70,7 @@ class City < ActiveRecord::Base
58
70
  end
59
71
 
60
72
  class SubTask < ActiveRecord::Base
73
+ acts_as_tenant :account
61
74
  belongs_to :something_else, :class_name => "Project"
62
75
  end
63
76
 
@@ -201,6 +214,5 @@ describe ActsAsTenant do
201
214
  describe "It should be possible to use aliased associations" do
202
215
  it { @sub_task = SubTask.create(:name => 'foo').valid?.should == true }
203
216
  end
204
-
205
217
 
206
218
  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.2
4
+ version: 0.2.3
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-10-09 00:00:00.000000000Z
12
+ date: 2011-11-20 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