diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-19 15:31:56 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-19 15:31:56 -0800 |
commit | 2df891dccdcfbdfb176c55297589712ac379f87d (patch) | |
tree | 0d2505faeaa910c2ef84ebcd70f45ab5d62bed99 /activerecord/test/cases/associations | |
parent | e0c6156c693efffd8009a116a96f7ff631e4db47 (diff) | |
download | rails-2df891dccdcfbdfb176c55297589712ac379f87d.tar.gz rails-2df891dccdcfbdfb176c55297589712ac379f87d.tar.bz2 rails-2df891dccdcfbdfb176c55297589712ac379f87d.zip |
eliminate warnings about multiple primary keys on habtm join tables
habtm join tables commonly have two id columns and it's OK to make those
two id columns a primary key. This commit eliminates the warnings for
join tables that have this setup.
ManageIQ/manageiq#6713
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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 5c4586da19..bae4197aaf 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 @@ -146,6 +146,19 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal 1, country.treaties.count end + def test_join_table_composit_primary_key_should_not_warn + country = Country.new(:name => 'India') + country.country_id = 'c1' + country.save! + + treaty = Treaty.new(:name => 'peace') + treaty.treaty_id = 't1' + warning = capture(:stderr) do + country.treaties << treaty + end + assert_no_match(/WARNING: Rails does not support composite primary key\./, warning) + end + def test_has_and_belongs_to_many david = Developer.find(1) |