From 98264a1343fad6bb6637893a37fd571916b4158c Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 2 May 2016 16:36:17 -0500 Subject: Do not delegate `AR::Base#empty?` to `all` Unlike `one?` and `none?`, `empty?` has interactions with methods outside of enumerable. It also doesn't fit in the same vein. `Topic.any?` makes sense. `Topic.empty?` does not, as `Topic` is not a container. Fixes #24808 Close #24812 --- activerecord/lib/active_record/querying.rb | 2 +- activerecord/test/cases/scoping/named_scoping_test.rb | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb index 4e32d73001..53ddd95bb0 100644 --- a/activerecord/lib/active_record/querying.rb +++ b/activerecord/lib/active_record/querying.rb @@ -1,6 +1,6 @@ module ActiveRecord module Querying - delegate :find, :take, :take!, :first, :first!, :last, :last!, :exists?, :any?, :many?, :empty?, :none?, :one?, to: :all + delegate :find, :take, :take!, :first, :first!, :last, :last!, :exists?, :any?, :many?, :none?, :one?, to: :all delegate :second, :second!, :third, :third!, :fourth, :fourth!, :fifth, :fifth!, :forty_two, :forty_two!, :third_to_last, :third_to_last!, :second_to_last, :second_to_last!, to: :all delegate :first_or_create, :first_or_create!, :first_or_initialize, to: :all delegate :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, to: :all diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 96c94eefa0..f05df9d76b 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -544,12 +544,6 @@ class NamedScopingTest < ActiveRecord::TestCase assert_equal 1, SpecialComment.where(body: 'go crazy').created.count end - def test_model_class_should_respond_to_empty - assert !Topic.empty? - Topic.delete_all - assert Topic.empty? - end - def test_model_class_should_respond_to_none assert !Topic.none? Topic.delete_all -- cgit v1.2.3