aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/relations_test.rb30
-rw-r--r--activerecord/test/cases/scoping/named_scoping_test.rb6
2 files changed, 22 insertions, 14 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 98ba47f1b8..2ac81ba425 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1169,9 +1169,11 @@ class RelationTest < ActiveRecord::TestCase
def test_first_or_create_with_after_initialize
Bird.create!(color: "yellow", name: "canary")
- parrot = Bird.where(color: "green").first_or_create do |bird|
- bird.name = "parrot"
- bird.enable_count = true
+ parrot = assert_deprecated do
+ Bird.where(color: "green").first_or_create do |bird|
+ bird.name = "parrot"
+ bird.enable_count = true
+ end
end
assert_equal 0, parrot.total_count
end
@@ -1180,7 +1182,7 @@ class RelationTest < ActiveRecord::TestCase
Bird.create!(color: "yellow", name: "canary")
parrot = Bird.where(color: "green").first_or_create do |bird|
bird.name = "parrot"
- assert_equal 0, Bird.count
+ assert_deprecated { assert_equal 0, Bird.count }
end
assert_kind_of Bird, parrot
assert_predicate parrot, :persisted?
@@ -1224,9 +1226,11 @@ class RelationTest < ActiveRecord::TestCase
def test_first_or_create_bang_with_after_initialize
Bird.create!(color: "yellow", name: "canary")
- parrot = Bird.where(color: "green").first_or_create! do |bird|
- bird.name = "parrot"
- bird.enable_count = true
+ parrot = assert_deprecated do
+ Bird.where(color: "green").first_or_create! do |bird|
+ bird.name = "parrot"
+ bird.enable_count = true
+ end
end
assert_equal 0, parrot.total_count
end
@@ -1235,7 +1239,7 @@ class RelationTest < ActiveRecord::TestCase
Bird.create!(color: "yellow", name: "canary")
parrot = Bird.where(color: "green").first_or_create! do |bird|
bird.name = "parrot"
- assert_equal 0, Bird.count
+ assert_deprecated { assert_equal 0, Bird.count }
end
assert_kind_of Bird, parrot
assert_predicate parrot, :persisted?
@@ -1287,9 +1291,11 @@ class RelationTest < ActiveRecord::TestCase
def test_first_or_initialize_with_after_initialize
Bird.create!(color: "yellow", name: "canary")
- parrot = Bird.where(color: "green").first_or_initialize do |bird|
- bird.name = "parrot"
- bird.enable_count = true
+ parrot = assert_deprecated do
+ Bird.where(color: "green").first_or_initialize do |bird|
+ bird.name = "parrot"
+ bird.enable_count = true
+ end
end
assert_equal 0, parrot.total_count
end
@@ -1298,7 +1304,7 @@ class RelationTest < ActiveRecord::TestCase
Bird.create!(color: "yellow", name: "canary")
parrot = Bird.where(color: "green").first_or_initialize do |bird|
bird.name = "parrot"
- assert_equal 0, Bird.count
+ assert_deprecated { assert_equal 0, Bird.count }
end
assert_kind_of Bird, parrot
assert_not_predicate parrot, :persisted?
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb
index 1a3a95f168..8b08e40468 100644
--- a/activerecord/test/cases/scoping/named_scoping_test.rb
+++ b/activerecord/test/cases/scoping/named_scoping_test.rb
@@ -50,7 +50,7 @@ class NamedScopingTest < ActiveRecord::TestCase
def test_calling_merge_at_first_in_scope
Topic.class_eval do
- scope :calling_merge_at_first_in_scope, Proc.new { merge(Topic.replied) }
+ scope :calling_merge_at_first_in_scope, Proc.new { merge(Topic.unscoped.replied) }
end
assert_equal Topic.calling_merge_at_first_in_scope.to_a, Topic.replied.to_a
end
@@ -448,7 +448,9 @@ class NamedScopingTest < ActiveRecord::TestCase
end
def test_class_method_in_scope
- assert_equal [topics(:second)], topics(:first).approved_replies.ordered
+ assert_deprecated do
+ assert_equal [topics(:second)], topics(:first).approved_replies.ordered
+ end
end
def test_nested_scoping