spec/db/schema.rb in goldiloader-0.0.3 vs spec/db/schema.rb in goldiloader-0.0.4
- old
+ new
@@ -58,25 +58,58 @@
class Blog < ActiveRecord::Base
has_many :posts
has_many :posts_without_auto_include, auto_include: false, class_name: 'Post'
has_many :posts_fully_load, fully_load: true, class_name: 'Post'
+
+ if ActiveRecord::VERSION::MAJOR >= 4
+ has_many :read_only_posts, -> { readonly }, class_name: 'Post'
+ has_many :limited_posts, -> { limit(2) }, class_name: 'Post'
+ has_many :grouped_posts, -> { group(:blog_id) }, class_name: 'Post'
+ has_many :offset_posts, -> { offset(2) }, class_name: 'Post'
+ has_many :from_posts, -> { from('(select distinct blog_id from posts) as posts') }, class_name: 'Post'
+ else
+ has_many :read_only_posts, readonly: true, class_name: 'Post'
+ has_many :limited_posts, limit: 2, class_name: 'Post'
+ has_many :grouped_posts, group: :blog_id, class_name: 'Post'
+ has_many :offset_posts, offset: 2, class_name: 'Post'
+ has_many :from_posts, finder_sql: Proc.new { "select distinct blog_id from posts where blog_id = #{self.id}" },
+ class_name: 'Post'
+ end
+
+ has_many :posts_overridden, class_name: 'Post'
has_many :authors, through: :posts
if Goldiloader::Compatibility.mass_assignment_security_enabled?
attr_accessible :name
end
+
+ def posts_overridden
+ 'boom'
+ end
end
class Post < ActiveRecord::Base
belongs_to :blog
belongs_to :blog_without_auto_include, auto_include: false, class_name: 'Blog', foreign_key: :blog_id
belongs_to :author, class_name: 'User'
has_many :post_tags
has_many :tags, through: :post_tags
+ if ActiveRecord::VERSION::MAJOR >= 4
+ has_many :unique_tags, -> { distinct }, through: :post_tags, source: :tag, class_name: 'Tag'
+ else
+ has_many :unique_tags, through: :post_tags, source: :tag, uniq: true, class_name: 'Tag'
+ end
+
+ after_destroy :after_post_destroy
+
if Goldiloader::Compatibility.mass_assignment_security_enabled?
attr_accessible :title
+ end
+
+ def after_post_destroy
+ # Hook for tests
end
end
class User < ActiveRecord::Base
has_many :posts, foreign_key: :author_id