test/setup_test_models.rb in activeshepherd-0.8.3 vs test/setup_test_models.rb in activeshepherd-0.8.4
- old
+ new
@@ -1,7 +1,8 @@
ActiveRecord::Migration.create_table :users, force: true do |t|
t.string :name
+ t.belongs_to :favorite_project
end
ActiveRecord::Migration.create_table :comments, force: true do |t|
t.string :text
t.string :type
@@ -42,10 +43,11 @@
class User < ActiveRecord::Base
act_as_aggregate_root!
has_many :projects, inverse_of: :owner, dependent: :destroy, autosave: true,
validate: true, foreign_key: :owner_id
+ belongs_to :favorite_project, class_name: "Project"
end
class Comment < ActiveRecord::Base
belongs_to :commentable, polymorphic: true, counter_cache: true
belongs_to :author, class_name: "User"
@@ -53,9 +55,11 @@
class Project < ActiveRecord::Base
act_as_aggregate_root!
belongs_to :owner, class_name: "User", inverse_of: :projects, touch: true
+ has_many :watchers, inverse_of: :favorite_project, class_name: "User",
+ foreign_key: :favorite_project_id
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