From 564922b32ceec259c442e965ac8a61ea5545bd48 Mon Sep 17 00:00:00 2001 From: Richard Millan Date: Thu, 5 May 2011 04:52:42 -0700 Subject: Testing identity map on inherited active record classes. Distinct models that use the same database table shouldn't be retrieved as the same object when there is not a type attribute. --- activerecord/test/cases/identity_map_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'activerecord/test/cases/identity_map_test.rb') diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index 649715fbb5..6cd29ed5b4 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -128,6 +128,23 @@ class IdentityMapTest < ActiveRecord::TestCase assert_same(t1, t2) end + ############################################################################## + # Tests checking if IM is functioning properly on classes with multiple # + # types of inheritance # + ############################################################################## + + 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 + c1 = comments(:sub_special_comment) + c2 = Comment.find(c1.id) + assert_same(c1, c2) + end + ############################################################################## # Tests checking dirty attribute behaviour with IM # ############################################################################## -- cgit v1.2.3