aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorWojciech Wnętrzak <w.wnetrzak@gmail.com>2015-09-05 10:50:05 +0200
committerWojciech Wnętrzak <w.wnetrzak@gmail.com>2015-09-06 16:14:16 +0200
commitc82c5f8ffd7291186235c5912151c9dc0d262c4a (patch)
treee881e9d357f4368158e03724cb241265c717f8ae /activerecord/test
parenta8f4568f5396b68ae81eddc636604bb78bb6632a (diff)
downloadrails-c82c5f8ffd7291186235c5912151c9dc0d262c4a.tar.gz
rails-c82c5f8ffd7291186235c5912151c9dc0d262c4a.tar.bz2
rails-c82c5f8ffd7291186235c5912151c9dc0d262c4a.zip
Deprecate passing conditions to AR::Relation destroy_all and delete_all methods
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/persistence_test.rb2
-rw-r--r--activerecord/test/cases/relations_test.rb12
-rw-r--r--activerecord/test/models/topic.rb2
3 files changed, 14 insertions, 2 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')
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index d17270021a..176bc79dc7 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -86,7 +86,7 @@ class Topic < ActiveRecord::Base
end
def destroy_children
- self.class.delete_all "parent_id = #{id}"
+ self.class.where("parent_id = #{id}").delete_all
end
def set_email_address