diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-12-27 19:35:55 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-12-27 21:15:12 +0530 |
commit | bbdeaae2cac37882b091474ec596ade3de3b5e7c (patch) | |
tree | 342800a91dd01e15ed68607a8b15fe162b984b48 /activerecord/test | |
parent | 5cd8818258cf7ce2c90667076d3f61f1c7ed548e (diff) | |
download | rails-bbdeaae2cac37882b091474ec596ade3de3b5e7c.tar.gz rails-bbdeaae2cac37882b091474ec596ade3de3b5e7c.tar.bz2 rails-bbdeaae2cac37882b091474ec596ade3de3b5e7c.zip |
Add relation.destroy_all
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 37bd755a5c..2ec8c0d3a2 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -315,4 +315,17 @@ class RelationTest < ActiveRecord::TestCase assert_equal authors(:mary), authors.last end + def test_destroy_all + davids = Author.where(:name => 'David') + + # Force load + assert_equal [authors(:david)], davids.to_a + assert davids.loaded? + + assert_difference('Author.count', -1) { davids.destroy_all } + + assert_equal [], davids.to_a + assert davids.loaded? + end + end |