diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-12-29 11:36:40 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-12-29 11:46:07 +0530 |
commit | 54b80c73611fe8eb19039381bf0322326f5e1b51 (patch) | |
tree | 701a8e76da825bc839cf0cde241c4ff994633273 /activerecord/test/cases | |
parent | f79caa49fb78bca986a4321830c4cd155c17e13a (diff) | |
download | rails-54b80c73611fe8eb19039381bf0322326f5e1b51.tar.gz rails-54b80c73611fe8eb19039381bf0322326f5e1b51.tar.bz2 rails-54b80c73611fe8eb19039381bf0322326f5e1b51.zip |
Add Relation#delete_all
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index ded4f2f479..92005fc224 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -329,6 +329,26 @@ class RelationTest < ActiveRecord::TestCase assert davids.loaded? end + def test_delete_all + davids = Author.where(:name => 'David') + + assert_difference('Author.count', -1) { davids.delete_all } + assert ! davids.loaded? + end + + def test_delete_all_loaded + davids = Author.where(:name => 'David') + + # Force load + assert_equal [authors(:david)], davids.to_a + assert davids.loaded? + + assert_difference('Author.count', -1) { davids.delete_all } + + assert_equal [], davids.to_a + assert davids.loaded? + end + def test_relation_merging devs = Developer.where("salary >= 80000") & Developer.limit(2) & Developer.order('id ASC').where("id < 3") assert_equal [developers(:david), developers(:jamis)], devs.to_a |