From fbebdb0c091c37b0bc75ab774d187d8bc8795bd2 Mon Sep 17 00:00:00 2001 From: Frederick Cheung Date: Fri, 2 May 2008 00:00:42 +0100 Subject: Ensure correct record is returned when preloading has_one where more than one row exists Signed-off-by: Michael Koziarski [#73 state:closed] --- activerecord/test/cases/associations/eager_test.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/test/cases/associations/eager_test.rb') diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 546ed80894..67b57ceb42 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -29,6 +29,10 @@ class EagerAssociationTest < ActiveRecord::TestCase post = Post.find(:first, :include => :comments, :conditions => "posts.title = 'Welcome to the weblog'") assert_equal 2, post.comments.size assert post.comments.include?(comments(:greetings)) + + posts = Post.find(:all, :include => :last_comment) + post = posts.find { |p| p.id == 1 } + assert_equal Post.find(1).last_comment, post.last_comment end def test_loading_conditions_with_or -- cgit v1.2.3