aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/class_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-12-01 14:53:31 -0500
committerSean Griffin <sean@seantheprogrammer.com>2016-12-01 14:53:31 -0500
commit4e73ffa9b45904492815f8f67d4695ef719e0350 (patch)
tree132461bb09747fd5a66fd40316578713a04c249c /activesupport/test/core_ext/class_test.rb
parent22042331650e943a1bb3f954fef7e2951e3ad2a3 (diff)
downloadrails-4e73ffa9b45904492815f8f67d4695ef719e0350.tar.gz
rails-4e73ffa9b45904492815f8f67d4695ef719e0350.tar.bz2
rails-4e73ffa9b45904492815f8f67d4695ef719e0350.zip
Exclude singleton classes from `subclasses` and `descendants`
This behavior changed in Ruby starting with 2.3.0, as a result of https://bugs.ruby-lang.org/issues/11360. This results in a change in behavior of these methods which is likely undesirable. Fixes #27238
Diffstat (limited to 'activesupport/test/core_ext/class_test.rb')
-rw-r--r--activesupport/test/core_ext/class_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb
index a9c44907cc..a7905196ae 100644
--- a/activesupport/test/core_ext/class_test.rb
+++ b/activesupport/test/core_ext/class_test.rb
@@ -25,4 +25,14 @@ class ClassTest < ActiveSupport::TestCase
assert_equal [Baz], Bar.subclasses
assert_equal [], Baz.subclasses
end
+
+ def test_descendants_excludes_singleton_classes
+ klass = Parent.new.singleton_class
+ refute Parent.descendants.include?(klass), "descendants should not include singleton classes"
+ end
+
+ def test_subclasses_excludes_singleton_classes
+ klass = Parent.new.singleton_class
+ refute Parent.subclasses.include?(klass), "subclasses should not include singleton classes"
+ end
end