提交 71312443 编写于 作者: J José Valim

Ensure default_scope can be overwriten by association conditions.

上级 d77c3b66
......@@ -259,6 +259,11 @@ def test_should_maintain_default_scope_on_associations
assert_equal [magician], people(:michael).bad_references
end
def test_should_default_scope_on_associations_is_overriden_by_association_conditions
person = people(:michael)
assert_equal [], people(:michael).fixed_bad_references
end
def test_should_maintain_default_scope_on_eager_loaded_associations
michael = Person.where(:id => people(:michael).id).includes(:bad_references).first
magician = BadReference.find(1)
......
......@@ -5,6 +5,7 @@ class Person < ActiveRecord::Base
has_many :references
has_many :bad_references
has_many :fixed_bad_references, :conditions => { :favourite => true }, :class_name => 'BadReference'
has_many :jobs, :through => :references
has_one :favourite_reference, :class_name => 'Reference', :conditions => ['favourite=?', true]
has_many :posts_with_comments_sorted_by_comment_id, :through => :readers, :source => :post, :include => :comments, :order => 'comments.id'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册