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:
parent
625741fcd1
commit
0e671acc18
|
@ -34,7 +34,11 @@ class Person < ActiveRecord::Base
|
||||||
has_many :children, class_name: 'Person', foreign_key: :parent_id
|
has_many :children, class_name: 'Person', foreign_key: :parent_id
|
||||||
has_many :articles
|
has_many :articles
|
||||||
if ActiveRecord::VERSION::MAJOR == 3
|
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
|
else
|
||||||
has_many :published_articles, ->{ where(published: true) }, class_name: "Article"
|
has_many :published_articles, ->{ where(published: true) }, class_name: "Article"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue