mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
safe_constantize should handle wrong constant name NameErrors Fixes #4710
This commit is contained in:
parent
82ba5c469f
commit
7598284c0b
2 changed files with 4 additions and 3 deletions
|
@ -243,7 +243,7 @@ module ActiveSupport
|
|||
begin
|
||||
constantize(camel_cased_word)
|
||||
rescue NameError => e
|
||||
raise unless e.message =~ /uninitialized constant #{const_regexp(camel_cased_word)}$/ ||
|
||||
raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ ||
|
||||
e.name.to_s == camel_cased_word.to_s
|
||||
rescue ArgumentError => e
|
||||
raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/
|
||||
|
|
|
@ -33,5 +33,6 @@ module ConstantizeTestCases
|
|||
assert_nothing_raised { assert_equal nil, yield("blargle") }
|
||||
assert_nothing_raised { assert_equal nil, yield("Ace::ConstantizeTestCases") }
|
||||
assert_nothing_raised { assert_equal nil, yield("Ace::Base::ConstantizeTestCases") }
|
||||
assert_nothing_raised { assert_equal nil, yield("#<Class:0x7b8b718b>::Nested_1") }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue