Skip to content

Commit

Permalink
Fix test suite for ActiveRecord version differences
Browse files Browse the repository at this point in the history
  • Loading branch information
avit committed Jul 10, 2015
1 parent 9f778e8 commit 7320bf9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spec/support/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7320bf9

Please sign in to comment.