aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorKevin Casey <kacasey@berkeley.edu>2014-02-02 11:47:06 -0800
committerKevin Casey <kacasey@berkeley.edu>2014-02-02 11:47:06 -0800
commit00ebbb79456dccd45d813886d81f1619c0161af4 (patch)
treec1a1fce780704382afc85a6abe8a12efa5c09d65 /activerecord/test
parentf484df79f26bca7e952f907878074eddbf72656d (diff)
downloadrails-00ebbb79456dccd45d813886d81f1619c0161af4.tar.gz
rails-00ebbb79456dccd45d813886d81f1619c0161af4.tar.bz2
rails-00ebbb79456dccd45d813886d81f1619c0161af4.zip
fix HABTM w/out primary key errors on destruction
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb10
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