test/test_helper.rb in destroyed_at-2.0.0 vs test/test_helper.rb in destroyed_at-2.1.0

- old
+ new

@@ -36,10 +36,11 @@ ActiveRecord::Base.connection.execute(%{CREATE TABLE destructive_children (id INTEGER PRIMARY KEY, person_id INTEGER, destroyed_at DATETIME);}) ActiveRecord::Base.connection.execute(%{CREATE TABLE images (id INTEGER PRIMARY KEY, post_id INTEGER);}) ActiveRecord::Base.connection.execute(%{CREATE TABLE posts (id INTEGER PRIMARY KEY, author_id INTEGER, destroyed_at DATETIME);}) ActiveRecord::Base.connection.execute(%{CREATE TABLE people (id INTEGER PRIMARY KEY);}) ActiveRecord::Base.connection.execute(%{CREATE TABLE pets (id INTEGER PRIMARY KEY, person_id INTEGER);}) +ActiveRecord::Base.connection.execute(%{CREATE TABLE likes (id INTEGER PRIMARY KEY, likeable_id INTEGER, likeable_type TEXT, destroyed_at DATETIME);}) class Author < ActiveRecord::Base has_many :posts has_one :avatar, dependent: :destroy end @@ -66,19 +67,26 @@ class Categorization < ActiveRecord::Base belongs_to :category belongs_to :post end +class Like < ActiveRecord::Base + include DestroyedAt + belongs_to :likeable, polymorphic: true +end + class Comment < ActiveRecord::Base include DestroyedAt belongs_to :post belongs_to :commenter + + has_many :likes, as: :likeable, dependent: :destroy end class Commenter < ActiveRecord::Base include DestroyedAt - has_many :comments, dependent: :destroy + has_many :comments, dependent: :destroy, autosave: true has_many :posts, through: :comments end class DestructiveChild < ActiveRecord::Base belongs_to :person, dependent: :destroy @@ -90,9 +98,10 @@ belongs_to :author has_many :categories, through: :categorizations has_many :categorizations, dependent: :destroy has_many :comments, dependent: :destroy has_many :commenters, through: :comments + has_one :like, as: :likeable, dependent: :destroy before_destroy :increment_destroy_callback_counter before_restore :increment_restore_callback_counter before_update :increment_update_callback_counter