aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2018-04-02 16:29:03 +0200
committerGitHub <noreply@github.com>2018-04-02 16:29:03 +0200
commitc9ad88fed18070fea1215e718c526c73b9a1cae2 (patch)
tree1e3b0b8d8553e61f40a9d436fb87d0d6f784a274 /activerecord/test/cases
parent0ec23effa74e8e9da6ebb14afbd335bea470ab3e (diff)
parent0d9f45ff99c092cce6b7642f653b8fdf9f930f0c (diff)
downloadrails-c9ad88fed18070fea1215e718c526c73b9a1cae2.tar.gz
rails-c9ad88fed18070fea1215e718c526c73b9a1cae2.tar.bz2
rails-c9ad88fed18070fea1215e718c526c73b9a1cae2.zip
Merge pull request #32417 from bogdan/base-class
Add AR::Base.base_class? predicate
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/attribute_methods/read_test.rb2
-rw-r--r--activerecord/test/cases/inheritance_test.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/attribute_methods/read_test.rb b/activerecord/test/cases/attribute_methods/read_test.rb
index 0170a6e98d..54512068ee 100644
--- a/activerecord/test/cases/attribute_methods/read_test.rb
+++ b/activerecord/test/cases/attribute_methods/read_test.rb
@@ -12,7 +12,7 @@ module ActiveRecord
def setup
@klass = Class.new(Class.new { def self.initialize_generated_modules; end }) do
def self.superclass; Base; end
- def self.base_class; self; end
+ def self.base_class?; true; end
def self.decorate_matching_attribute_types(*); end
include ActiveRecord::DefineCallbacks
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb
index e3ca79af99..7a5c06b894 100644
--- a/activerecord/test/cases/inheritance_test.rb
+++ b/activerecord/test/cases/inheritance_test.rb
@@ -174,17 +174,26 @@ class InheritanceTest < ActiveRecord::TestCase
def test_inheritance_base_class
assert_equal Post, Post.base_class
+ assert_predicate Post, :base_class?
assert_equal Post, SpecialPost.base_class
+ assert_not_predicate SpecialPost, :base_class?
assert_equal Post, StiPost.base_class
+ assert_not_predicate StiPost, :base_class?
assert_equal Post, SubStiPost.base_class
+ assert_not_predicate SubStiPost, :base_class?
assert_equal SubAbstractStiPost, SubAbstractStiPost.base_class
+ assert_predicate SubAbstractStiPost, :base_class?
end
def test_abstract_inheritance_base_class
assert_equal LoosePerson, LoosePerson.base_class
+ assert_predicate LoosePerson, :base_class?
assert_equal LooseDescendant, LooseDescendant.base_class
+ assert_predicate LooseDescendant, :base_class?
assert_equal TightPerson, TightPerson.base_class
+ assert_predicate TightPerson, :base_class?
assert_equal TightPerson, TightDescendant.base_class
+ assert_not_predicate TightDescendant, :base_class?
end
def test_base_class_activerecord_error