aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/scoping
diff options
context:
space:
mode:
authorDaniel Colson <danieljamescolson@gmail.com>2018-01-25 18:16:57 -0500
committerDaniel Colson <danieljamescolson@gmail.com>2018-01-25 23:32:59 -0500
commit82c39e1a0b5114e2d89a80883a41090567a83196 (patch)
tree476f620e0224130ca3dca3ed4e9b5a58fb0d5da9 /activerecord/test/cases/scoping
parent94333a4c31bd10c1f358c538a167e6a4589bae2d (diff)
downloadrails-82c39e1a0b5114e2d89a80883a41090567a83196.tar.gz
rails-82c39e1a0b5114e2d89a80883a41090567a83196.tar.bz2
rails-82c39e1a0b5114e2d89a80883a41090567a83196.zip
Use assert_empty and assert_not_empty
Diffstat (limited to 'activerecord/test/cases/scoping')
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb4
-rw-r--r--activerecord/test/cases/scoping/named_scoping_test.rb20
2 files changed, 12 insertions, 12 deletions
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index 70d1aa5fff..0804de1fb3 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -302,8 +302,8 @@ class DefaultScopingTest < ActiveRecord::TestCase
def test_unscope_merging
merged = Developer.where(name: "Jamis").merge(Developer.unscope(:where))
- assert_predicate merged.where_clause, :empty?
- assert_not_predicate merged.where(name: "Jon").where_clause, :empty?
+ assert_empty merged.where_clause
+ assert_not_empty merged.where(name: "Jon").where_clause
end
def test_order_in_default_scope_should_not_prevail
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb
index 7d206054ca..ea71a5ce28 100644
--- a/activerecord/test/cases/scoping/named_scoping_test.rb
+++ b/activerecord/test/cases/scoping/named_scoping_test.rb
@@ -13,7 +13,7 @@ class NamedScopingTest < ActiveRecord::TestCase
fixtures :posts, :authors, :topics, :comments, :author_addresses
def test_implements_enumerable
- assert_not_predicate Topic.all, :empty?
+ assert_not_empty Topic.all
assert_equal Topic.all.to_a, Topic.base
assert_equal Topic.all.to_a, Topic.base.to_a
@@ -40,7 +40,7 @@ class NamedScopingTest < ActiveRecord::TestCase
end
def test_delegates_finds_and_calculations_to_the_base_class
- assert_not_predicate Topic.all, :empty?
+ assert_not_empty Topic.all
assert_equal Topic.all.to_a, Topic.base.to_a
assert_equal Topic.first, Topic.base.first
@@ -71,7 +71,7 @@ class NamedScopingTest < ActiveRecord::TestCase
end
def test_scopes_with_options_limit_finds_to_those_matching_the_criteria_specified
- assert_not_predicate Topic.all.merge!(where: { approved: true }).to_a, :empty?
+ assert_not_empty Topic.all.merge!(where: { approved: true }).to_a
assert_equal Topic.all.merge!(where: { approved: true }).to_a, Topic.approved
assert_equal Topic.where(approved: true).count, Topic.approved.count
@@ -87,7 +87,7 @@ class NamedScopingTest < ActiveRecord::TestCase
assert_equal((approved = Topic.all.merge!(where: { approved: true }).to_a), Topic.approved)
assert_equal((replied = Topic.all.merge!(where: "replies_count > 0").to_a), Topic.replied)
assert !(approved == replied)
- assert_not_predicate (approved & replied), :empty?
+ assert_not_empty (approved & replied)
assert_equal approved & replied, Topic.approved.replied
end
@@ -115,7 +115,7 @@ class NamedScopingTest < ActiveRecord::TestCase
def test_has_many_associations_have_access_to_scopes
assert_not_equal Post.containing_the_letter_a, authors(:david).posts
- assert_not_predicate Post.containing_the_letter_a, :empty?
+ assert_not_empty Post.containing_the_letter_a
expected = authors(:david).posts & Post.containing_the_letter_a
assert_equal expected.sort_by(&:id), authors(:david).posts.containing_the_letter_a.sort_by(&:id)
@@ -128,15 +128,15 @@ class NamedScopingTest < ActiveRecord::TestCase
def test_has_many_through_associations_have_access_to_scopes
assert_not_equal Comment.containing_the_letter_e, authors(:david).comments
- assert_not_predicate Comment.containing_the_letter_e, :empty?
+ assert_not_empty Comment.containing_the_letter_e
expected = authors(:david).comments & Comment.containing_the_letter_e
assert_equal expected.sort_by(&:id), authors(:david).comments.containing_the_letter_e.sort_by(&:id)
end
def test_scopes_honor_current_scopes_from_when_defined
- assert_not_predicate Post.ranked_by_comments.limit_by(5), :empty?
- assert_not_predicate authors(:david).posts.ranked_by_comments.limit_by(5), :empty?
+ assert_not_empty Post.ranked_by_comments.limit_by(5)
+ assert_not_empty authors(:david).posts.ranked_by_comments.limit_by(5)
assert_not_equal Post.ranked_by_comments.limit_by(5), authors(:david).posts.ranked_by_comments.limit_by(5)
assert_not_equal Post.top(5), authors(:david).posts.top(5)
# Oracle sometimes sorts differently if WHERE condition is changed
@@ -168,14 +168,14 @@ class NamedScopingTest < ActiveRecord::TestCase
end
def test_active_records_have_scope_named__all__
- assert_not_predicate Topic.all, :empty?
+ assert_not_empty Topic.all
assert_equal Topic.all.to_a, Topic.base
end
def test_active_records_have_scope_named__scoped__
scope = Topic.where("content LIKE '%Have%'")
- assert_not_predicate scope, :empty?
+ assert_not_empty scope
assert_equal scope, Topic.all.merge!(where: "content LIKE '%Have%'")
end