diff options
author | Kristijan Novoselic <kristijan@glooko.com> | 2015-06-09 19:00:24 +0200 |
---|---|---|
committer | Kristijan Novoselic <kristijan@glooko.com> | 2015-06-12 17:35:21 +0200 |
commit | f98e75a3e2b1665bd1da28b9456a296cc3c35bbc (patch) | |
tree | 05f2a8d37d15c34de3acd7fb7d44e4787d73fe2b /activesupport/test | |
parent | 0b57f090c95503a14dfb3473752fecc658527d16 (diff) | |
download | rails-f98e75a3e2b1665bd1da28b9456a296cc3c35bbc.tar.gz rails-f98e75a3e2b1665bd1da28b9456a296cc3c35bbc.tar.bz2 rails-f98e75a3e2b1665bd1da28b9456a296cc3c35bbc.zip |
Fix for #20489 - ActiveSupport::Concern#class_methods affects parent classes
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/concern_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activesupport/test/concern_test.rb b/activesupport/test/concern_test.rb index 253c1adc23..8ea701cfb7 100644 --- a/activesupport/test/concern_test.rb +++ b/activesupport/test/concern_test.rb @@ -54,6 +54,11 @@ class ConcernTest < ActiveSupport::TestCase include Bar, Baz end + module Qux + module ClassMethods + end + end + def setup @klass = Class.new end @@ -70,6 +75,26 @@ class ConcernTest < ActiveSupport::TestCase assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0] end + def test_class_methods_are_extended_only_on_expected_objects + ::Object.__send__(:include, Qux) + Object.extend(Qux::ClassMethods) + # module needs to be created after Qux is included in Object or bug won't + # be triggered + test_module = Module.new do + extend ActiveSupport::Concern + + class_methods do + def test + end + end + end + @klass.include test_module + assert_equal false, Object.respond_to?(:test) + Qux.class_eval do + remove_const :ClassMethods + end + end + def test_included_block_is_ran @klass.include(Baz) assert_equal true, @klass.included_ran |