diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index dbe098bbccd9..97eb969d9955 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -281,9 +281,7 @@ def constantize(camel_cased_word) names.shift if names.empty? || names.first.empty? constant = Object - names.each do |name| - constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) - end + names.each { |name| constant = constant.const_get(name) } constant end diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 4ce9cbb705af..c586b456de95 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -2,8 +2,21 @@ require 'inflector_test_cases' module Ace + module Extension + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + def mission_accomplished? + false + end + end + end + module Base class Case + include Extension end end end @@ -121,7 +134,9 @@ def test_constantize end def test_constantize_does_lexical_lookup - assert_raises(NameError) { ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") } + assert_equal InflectorTest, ActiveSupport::Inflector.constantize("Ace::Base::InflectorTest") + assert_nothing_raised { Ace::Base::Case::ClassMethods } + assert_nothing_raised { assert_equal Ace::Base::Case::ClassMethods, ActiveSupport::Inflector.constantize("Ace::Base::Case::ClassMethods") } end def test_ordinal