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.
This commit is contained in:
Jon Atack 2015-12-26 08:04:45 +01:00
parent 625741fcd1
commit 0e671acc18
1 changed files with 5 additions and 1 deletions

View File

@ -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