diff options
author | Matthew Draper <matthew@trebex.net> | 2015-09-07 00:10:50 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2015-09-07 00:10:50 +0930 |
commit | e07b006d9c7b0a57c350d918259176089d6dedd6 (patch) | |
tree | 4a10983dc01217aee4c8f2e620fd3d77fcea8927 /activerecord/test/cases | |
parent | bc1f0c2e36ee705023dcbd513d99f834f8262ea3 (diff) | |
parent | c82c5f8ffd7291186235c5912151c9dc0d262c4a (diff) | |
download | rails-e07b006d9c7b0a57c350d918259176089d6dedd6.tar.gz rails-e07b006d9c7b0a57c350d918259176089d6dedd6.tar.bz2 rails-e07b006d9c7b0a57c350d918259176089d6dedd6.zip |
Merge pull request #21505 from morgoth/deprecate-passing-conditions-to-destroy_all-and-delete_all
Deprecate passing conditions to AR::Relation destroy_all and delete_all methods
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index cdf63957f4..7f14082a9a 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -126,7 +126,7 @@ class PersistenceTest < ActiveRecord::TestCase assert ! topics_by_mary.empty? assert_difference('Topic.count', -topics_by_mary.size) do - destroyed = Topic.destroy_all(conditions).sort_by(&:id) + destroyed = Topic.where(conditions).destroy_all.sort_by(&:id) assert_equal topics_by_mary, destroyed assert destroyed.all?(&:frozen?), "destroyed topics should be frozen" end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 5f48c2b40f..8256762f96 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -931,6 +931,12 @@ class RelationTest < ActiveRecord::TestCase assert davids.loaded? end + def test_destroy_all_with_conditions_is_deprecated + assert_deprecated do + assert_difference('Author.count', -1) { Author.destroy_all(name: 'David') } + end + end + def test_delete_all davids = Author.where(:name => 'David') @@ -938,6 +944,12 @@ class RelationTest < ActiveRecord::TestCase assert ! davids.loaded? end + def test_delete_all_with_conditions_is_deprecated + assert_deprecated do + assert_difference('Author.count', -1) { Author.delete_all(name: 'David') } + end + end + def test_delete_all_loaded davids = Author.where(:name => 'David') |