From 7320bf9c5a972c151d963b9c6e3a15787c87b46d Mon Sep 17 00:00:00 2001 From: Andrew Vit Date: Fri, 10 Jul 2015 13:24:19 -0700 Subject: [PATCH] Fix test suite for ActiveRecord version differences --- spec/support/schema.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/support/schema.rb b/spec/support/schema.rb index 7966137..735b056 100644 --- a/spec/support/schema.rb +++ b/spec/support/schema.rb @@ -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