From 1f7c3d02645c6b72e5d1428bc7da6668cdee5fa8 Mon Sep 17 00:00:00 2001 From: Marian Rudzynski Date: Thu, 26 May 2011 11:00:27 +0200 Subject: use association_primary_key in AssociationScope#add_constraints --- .../associations/has_and_belongs_to_many_associations_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index f4d14853d3..b8442656ee 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -100,6 +100,13 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal 'c1', record[0] assert_equal 't1', record[1] end + + def test_proper_usage_of_primary_keys_and_join_table + setup_data_for_habtm_case + + country = Country.first + assert_equal 1, country.treaties.count + end def test_has_and_belongs_to_many david = Developer.find(1) -- cgit v1.2.3 From f4ed56df43b1f88dca46b1a343ede55e649b327e Mon Sep 17 00:00:00 2001 From: Marian Rudzynski Date: Thu, 26 May 2011 12:40:09 +0200 Subject: added assertion for non-standard primary_key on models used in the primary_key test --- .../cases/associations/has_and_belongs_to_many_associations_test.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index b8442656ee..839a7852fc 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -104,6 +104,9 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase def test_proper_usage_of_primary_keys_and_join_table setup_data_for_habtm_case + assert_equal 'country_id', Country.primary_key + assert_equal 'treaty_id', Treaty.primary_key + country = Country.first assert_equal 1, country.treaties.count end -- cgit v1.2.3