diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-04 04:11:46 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-02-04 04:11:46 -0800 |
commit | 702e0e1a6b6d776b0527f68d78a50714312fe149 (patch) | |
tree | dc91df099ccc119b5180830de6e39f0774bb65d4 /activerecord/test | |
parent | 7d196cf360321466c0eefc474bfad1be7e3ea7ab (diff) | |
parent | 00ebbb79456dccd45d813886d81f1619c0161af4 (diff) | |
download | rails-702e0e1a6b6d776b0527f68d78a50714312fe149.tar.gz rails-702e0e1a6b6d776b0527f68d78a50714312fe149.tar.bz2 rails-702e0e1a6b6d776b0527f68d78a50714312fe149.zip |
Merge pull request #13899 from Fortisque/kevin/active_record_HABTM_with_belongs_to
destruction errors out on HABTM w/out primary key
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 10 |
1 files changed, 10 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 8aee7ff40e..bac1cb8e2d 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 @@ -775,6 +775,16 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert project.developers.include?(developer) end + def test_destruction_does_not_error_without_primary_key + redbeard = pirates(:redbeard) + george = parrots(:george) + redbeard.parrots << george + assert_equal 2, george.pirates.count + Pirate.includes(:parrots).where(parrot: redbeard.parrot).find(redbeard.id).destroy + assert_equal 1, george.pirates.count + assert_equal [], Pirate.where(id: redbeard.id) + end + test "has and belongs to many associations on new records use null relations" do projects = Developer.new.projects assert_no_queries do |