aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-18 13:43:44 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-18 13:43:44 -0700
commit3e2f0800e33cc056d344a45557815b19463ab416 (patch)
tree617b18720b5ce1beda64c478845538756509cb2c /activerecord/test/cases/associations/has_many_through_associations_test.rb
parent87adecfef59577be17a9731245cb201ecb1b477f (diff)
parentcef76c8af4705dc60f85a721e3a14adb99418d33 (diff)
downloadrails-3e2f0800e33cc056d344a45557815b19463ab416.tar.gz
rails-3e2f0800e33cc056d344a45557815b19463ab416.tar.bz2
rails-3e2f0800e33cc056d344a45557815b19463ab416.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 97efca7891..51c70b9819 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -93,7 +93,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
def test_destroy_association
- assert_difference "Person.count", -1 do
+ assert_difference ["Person.count", "Reader.count"], -1 do
posts(:welcome).people.destroy(people(:michael))
end
@@ -102,7 +102,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
def test_destroy_all
- assert_difference "Person.count", -1 do
+ assert_difference ["Person.count", "Reader.count"], -1 do
posts(:welcome).people.destroy_all
end
@@ -110,6 +110,12 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert posts(:welcome).people(true).empty?
end
+ def test_should_raise_exception_for_destroying_mismatching_records
+ assert_no_difference ["Person.count", "Reader.count"] do
+ assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:welcome).people.destroy(posts(:thinking)) }
+ end
+ end
+
def test_replace_association
assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)}