test/setup_test_models.rb in activeshepherd-0.8.2 vs test/setup_test_models.rb in activeshepherd-0.8.3
- old
+ new
@@ -37,20 +37,25 @@
t.belongs_to :todo
t.belongs_to :assignee
end
-User = Class.new(ActiveRecord::Base)
+class User < ActiveRecord::Base
+ act_as_aggregate_root!
+ has_many :projects, inverse_of: :owner, dependent: :destroy, autosave: true,
+ validate: true, foreign_key: :owner_id
+end
+
class Comment < ActiveRecord::Base
belongs_to :commentable, polymorphic: true, counter_cache: true
belongs_to :author, class_name: "User"
end
class Project < ActiveRecord::Base
act_as_aggregate_root!
- belongs_to :owner, class_name: "User"
+ belongs_to :owner, class_name: "User", inverse_of: :projects, touch: true
has_one :detail, inverse_of: :project, dependent: :destroy, autosave: true
has_many :todo_lists, validate: true, dependent: :destroy, inverse_of: :project, autosave: true
has_many :todos, through: :todo_lists # not part of aggregate