Fixed that association proxies would fail === tests like PremiumSubscription...

Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@476 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 d336ca52
*SVN*
* Fixed that association proxies would fail === tests like PremiumSubscription === @account.subscription
* Fixed that column aliases didn't work as expected with the new MySql411 driver #507 [Demetrius]
* Fixed that find_all would produce invalid sql when called sequentialy #490 [Scott Baron]
......
......@@ -598,6 +598,11 @@ def benchmark(title)
return result
end
# Overwrite the default class equality method to provide support for association proxies.
def ===(object)
object.is_a?(self)
end
private
# Finder methods must instantiate through this method to work with the single-table inheritance model
# that makes it possible to create objects of different types from the same table.
......
......@@ -74,6 +74,10 @@ def test_has_one
assert_equal Account.find(1).credit_limit, @signals37.account.credit_limit
end
def test_triple_equality
assert Account === @signals37.account
end
def test_type_mismatch
assert_raises(ActiveRecord::AssociationTypeMismatch) { @signals37.account = 1 }
assert_raises(ActiveRecord::AssociationTypeMismatch) { @signals37.account = Project.find(1) }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册