From 28dc423094a80ff5ce45027281ab96df52657dc3 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 18 Mar 2010 11:58:02 -0700 Subject: [PATCH] Spec for identity map change --- spec/extensions/identity_map_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/extensions/identity_map_spec.rb b/spec/extensions/identity_map_spec.rb index d5742df61a..43df4ba69d 100644 --- a/spec/extensions/identity_map_spec.rb +++ b/spec/extensions/identity_map_spec.rb @@ -155,6 +155,22 @@ class ::IdentityMapArtist < ::IdentityMapModel end end + it "should not use the identity map as a lookup cache for a one_to_one association" do + c = @c2 + @c2.one_to_one :artist, :class=>@c1, :key=>:artist_id + @c.with_identity_map do + MODEL_DB.sqls.length.should == 0 + o = @c2.load(:id=>2) + a = o.artist + a.should be_a_kind_of(@c1) + MODEL_DB.sqls.length.should == 1 + o.reload + MODEL_DB.sqls.length.should == 2 + o.artist.should == a + MODEL_DB.sqls.length.should == 3 + end + end + it "should not use the identity map as a lookup cache if the assocation has a nil :key option" do c = @c2 @c1.many_to_one :artist, :class=>@c2, :key=>nil, :dataset=>proc{c.filter(:artist_id=>artist_id)}