aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-07 17:33:40 +0200
committerJosé Valim <jose.valim@gmail.com>2011-05-07 17:33:40 +0200
commit5d6c8d5e9d1c6544f8db8639e3a53a8d7682eeb2 (patch)
treecfe6165eadd5b11d41d0b057618e7071847a030d /activerecord/test
parent00a1152fa79808dfa86a516fe150911297f7aa58 (diff)
downloadrails-5d6c8d5e9d1c6544f8db8639e3a53a8d7682eeb2.tar.gz
rails-5d6c8d5e9d1c6544f8db8639e3a53a8d7682eeb2.tar.bz2
rails-5d6c8d5e9d1c6544f8db8639e3a53a8d7682eeb2.zip
Revert "Revert the merge because tests did not pass."
This reverts commit 886818d2bab40585c0cea763002ffc16917dd0b3.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/identity_map_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb
index 649715fbb5..a0e16400d2 100644
--- a/activerecord/test/cases/identity_map_test.rb
+++ b/activerecord/test/cases/identity_map_test.rb
@@ -129,6 +129,41 @@ class IdentityMapTest < ActiveRecord::TestCase
end
##############################################################################
+ # Tests checking if IM is functioning properly on classes with multiple #
+ # types of inheritance #
+ ##############################################################################
+
+ def test_inherited_without_type_attribute_without_identity_map
+ ActiveRecord::IdentityMap.without do
+ p1 = DestructivePirate.create!(:catchphrase => "I'm not a regular Pirate")
+ p2 = Pirate.find(p1.id)
+ assert_not_same(p1, p2)
+ end
+ end
+
+ def test_inherited_with_type_attribute_without_identity_map
+ ActiveRecord::IdentityMap.without do
+ c = comments(:sub_special_comment)
+ c1 = SubSpecialComment.find(c.id)
+ c2 = Comment.find(c.id)
+ assert_same(c1.class, c2.class)
+ end
+ end
+
+ def test_inherited_without_type_attribute
+ p1 = DestructivePirate.create!(:catchphrase => "I'm not a regular Pirate")
+ p2 = Pirate.find(p1.id)
+ assert_not_same(p1, p2)
+ end
+
+ def test_inherited_with_type_attribute
+ c = comments(:sub_special_comment)
+ c1 = SubSpecialComment.find(c.id)
+ c2 = Comment.find(c.id)
+ assert_same(c1, c2)
+ end
+
+ ##############################################################################
# Tests checking dirty attribute behaviour with IM #
##############################################################################