test/test_helper.rb in destroyed_at-0.4.0 vs test/test_helper.rb in destroyed_at-1.0.0
- old
+ new
@@ -26,18 +26,25 @@
)
DatabaseCleaner.strategy = :truncation
ActiveRecord::Base.connection.execute(%{CREATE TABLE authors (id INTEGER PRIMARY KEY);})
+ActiveRecord::Base.connection.execute(%{CREATE TABLE avatars (id INTEGER PRIMARY KEY, author_id INTEGER, destroyed_at DATETIME);})
ActiveRecord::Base.connection.execute(%{CREATE TABLE categories (id INTEGER PRIMARY KEY);})
ActiveRecord::Base.connection.execute(%{CREATE TABLE categorizations (id INTEGER PRIMARY KEY, category_id INTEGER, post_id INTEGER);})
ActiveRecord::Base.connection.execute(%{CREATE TABLE comments (id INTEGER PRIMARY KEY, commenter_id INTEGER, post_id INTEGER, destroyed_at DATETIME);})
ActiveRecord::Base.connection.execute(%{CREATE TABLE commenters (id INTEGER PRIMARY KEY, 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);})
class Author < ActiveRecord::Base
has_many :posts
+ has_one :avatar, dependent: :destroy
+end
+
+class Avatar < ActiveRecord::Base
+ include DestroyedAt
+ belongs_to :author
end
class Category < ActiveRecord::Base
has_many :categorizations
has_many :posts, through: :categorizations