diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-09-15 15:38:38 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-11-19 19:08:09 -0300 |
commit | 234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88 (patch) | |
tree | d8835097cfe5c4d63eadf35ddfabd612ce101b18 /activerecord/test/cases/identity_map_test.rb | |
parent | 6b0b95f1bd92e2ef35573cb59e8a14bd3ffb3777 (diff) | |
download | rails-234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88.tar.gz rails-234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88.tar.bz2 rails-234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88.zip |
Associated objects are assigned from identity map if enabled and contains associated object.
Diffstat (limited to 'activerecord/test/cases/identity_map_test.rb')
-rw-r--r-- | activerecord/test/cases/identity_map_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index 7deda56541..e62e99361a 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -287,4 +287,22 @@ class IdentityMapTest < ActiveRecord::TestCase assert_not_equal developer.salary, same_developer.salary end + def test_owner_object_is_associated_from_identity_map + post = Post.find(1) + comment = post.comments.first + + assert_no_queries do + comment.post + end + assert_same post, comment.post + end + + def test_associated_object_are_assigned_from_identity_map + post = Post.find(1) + + post.comments.each do |comment| + assert_same post, comment.post + assert_equal post.object_id, comment.post.target.object_id + end + end end |