From 13e9dcebad6b67aaf152a3b2281616ea28ceb7a6 Mon Sep 17 00:00:00 2001 From: Ernie Miller Date: Wed, 5 May 2010 16:39:51 -0400 Subject: [PATCH] Test for belongs_to with :primary key option joins --- .../associations/belongs_to_associations_test.rb | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index be77ee4..8e3dad1 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -42,6 +42,11 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_match(/"firm_with_primary_keys_companies"\."name"/, sql) end end + + def test_belongs_to_with_primary_key_joining_association_returns_correct_result + client = Client.create(:name => "Awesome, Inc.", :firm_name => companies(:first_firm).name) + assert_equal client, Client.joins(:firm_with_primary_key).where("firm_with_primary_keys_companies.name = ?", companies(:first_firm).name).last + end def test_proxy_assignment account = Account.find(1) -- 1.6.4.4