aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb5
-rwxr-xr-xactiverecord/test/associations_test.rb4
3 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index e006a34edc..65174cb1b8 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*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]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 5af24caeef..bae91da22d 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -598,6 +598,11 @@ module ActiveRecord #:nodoc:
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.
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 0e992526bc..420fae069b 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -74,6 +74,10 @@ class HasOneAssociationsTest < Test::Unit::TestCase
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) }