From 1c88d59891d11bd60a07f35a15c0043e0f8cf28a Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 18 Nov 2010 11:03:25 -0300 Subject: Add test using identity map and select. --- activerecord/test/cases/identity_map_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index df77bc5af2..74d4cb0bfb 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -366,6 +366,20 @@ class IdentityMapTest < ActiveRecord::TestCase assert comment.save end + def test_find_using_select_and_identity_map + author_id, author = Author.select('id').first, Author.first + + assert_equal author_id, author + assert_same author_id, author + assert_not_nil author.name + + post, post_id = Post.first, Post.select('id').first + + assert_equal post_id, post + assert_same post_id, post + assert_not_nil post.title + end + # Currently AR is not allowing changing primary key (see Persistence#update) # So we ignore it. If this changes, this test needs to be uncommented. # def test_updating_of_pkey -- cgit v1.2.3