Skip to content

Commit

Permalink
Spec for identity map change
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Mar 18, 2010
1 parent 305737f commit 28dc423
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/extensions/identity_map_spec.rb
Expand Up @@ -155,6 +155,22 @@ class ::IdentityMapArtist < ::IdentityMapModel
end end
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 it "should not use the identity map as a lookup cache if the assocation has a nil :key option" do
c = @c2 c = @c2
@c1.many_to_one :artist, :class=>@c2, :key=>nil, :dataset=>proc{c.filter(:artist_id=>artist_id)} @c1.many_to_one :artist, :class=>@c2, :key=>nil, :dataset=>proc{c.filter(:artist_id=>artist_id)}
Expand Down

0 comments on commit 28dc423

Please sign in to comment.