aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorKelley Reynolds <kelley@insidesystems.net>2012-02-09 13:51:40 -0500
committerKelley Reynolds <kelley@insidesystems.net>2012-02-09 13:51:40 -0500
commit6050d0177c3b9dc11c3e3c3dfa17530e27d90996 (patch)
tree749d9f1413d6c1c5602cea04c3af07c1cc0e98c7 /activerecord/test/cases/associations
parentb02c87ef2a22f01b4dcaae2663ed64284880b8fc (diff)
downloadrails-6050d0177c3b9dc11c3e3c3dfa17530e27d90996.tar.gz
rails-6050d0177c3b9dc11c3e3c3dfa17530e27d90996.tar.bz2
rails-6050d0177c3b9dc11c3e3c3dfa17530e27d90996.zip
Fix eagerly loading associations without primary keys
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index b79c69bbb5..35070ba506 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -39,6 +39,19 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_nil member.favourite_club
end
+ def test_loading_with_one_association_without_primary_key
+ Comment.primary_key = nil
+ begin
+ assert_nothing_raised do
+ Post.includes(:comments).references(:comments).all
+ end
+ rescue
+ raise $!
+ ensure
+ Comment.primary_key = 'id'
+ end
+ end
+
def test_loading_with_one_association
posts = Post.find(:all, :include => :comments)
post = posts.find { |p| p.id == 1 }