Fix test suite for ActiveRecord version differences

This commit is contained in:
Andrew Vit 2015-07-10 13:24:19 -07:00
parent 9f778e8c6c
commit 7320bf9c5a
1 changed files with 5 additions and 1 deletions

View File

@ -33,7 +33,11 @@ class Person < ActiveRecord::Base
belongs_to :parent, :class_name => 'Person', :foreign_key => :parent_id
has_many :children, :class_name => 'Person', :foreign_key => :parent_id
has_many :articles
has_many :published_articles, :class_name => 'Article', :conditions => {published: true}
if ActiveRecord::VERSION::MAJOR == 3
has_many :published_articles, conditions: { published: true }, class_name: "Article"
else
has_many :published_articles, ->{ where(published: true) }, class_name: "Article"
end
has_many :comments
has_many :authored_article_comments, :through => :articles,
:source => :comments, :foreign_key => :person_id