mirror of https://github.com/rails/rails
Fix `ActiveSupport::Inflector.humanize(nil)`
This commit is contained in:
parent
06e8bb5b4c
commit
016b81f0b2
|
@ -1,3 +1,7 @@
|
|||
* Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError: undefined method `end_with?' for nil:NilClass``.
|
||||
|
||||
*James Robinson*
|
||||
|
||||
* Don't show secrets for `ActiveSupport::KeyGenerator#inspect`.
|
||||
|
||||
Before:
|
||||
|
|
|
@ -139,7 +139,7 @@ module ActiveSupport
|
|||
|
||||
result.tr!("_", " ")
|
||||
result.lstrip!
|
||||
if !keep_id_suffix && lower_case_and_underscored_word.end_with?("_id")
|
||||
if !keep_id_suffix && lower_case_and_underscored_word&.end_with?("_id")
|
||||
result.delete_suffix!(" id")
|
||||
end
|
||||
|
||||
|
|
|
@ -380,6 +380,10 @@ class InflectorTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_humanize_nil
|
||||
assert_equal("", ActiveSupport::Inflector.humanize(nil))
|
||||
end
|
||||
|
||||
def test_humanize_without_capitalize
|
||||
UnderscoreToHumanWithoutCapitalize.each do |underscore, human|
|
||||
assert_equal(human, ActiveSupport::Inflector.humanize(underscore, capitalize: false))
|
||||
|
|
Loading…
Reference in New Issue