From 0e671acc188ce6f3484459e5bfe1f2b42358c35c Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Sat, 26 Dec 2015 08:04:45 +0100 Subject: [PATCH] Fix specs broken by Rails 3 on Ruby 2.3.0. With the new Ruby 2.3.0, Active Record 3 association conditions are not being recognized when using hash syntax instead of SQL string literals. Using string literals makes the spec work again, but it may be worth checking whether it is Ransack or Active Record that is breaking with Ruby 2.3.0 on this issue. --- 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 624069a..5a9ada3 100644 --- a/spec/support/schema.rb +++ b/spec/support/schema.rb @@ -34,7 +34,11 @@ class Person < ActiveRecord::Base has_many :children, class_name: 'Person', foreign_key: :parent_id has_many :articles if ActiveRecord::VERSION::MAJOR == 3 - has_many :published_articles, conditions: { published: true }, class_name: "Article" + if RUBY_VERSION >= '2.3' + has_many :published_articles, class_name: "Article", conditions: "published = 't'" + else + has_many :published_articles, class_name: "Article", conditions: { published: true } + end else has_many :published_articles, ->{ where(published: true) }, class_name: "Article" end