Fix `humanize` for strings ending with ` id`

This commit is contained in:
fatkodima 2023-05-31 02:14:10 +03:00
parent ae02cd6539
commit e3c546eb0c
2 changed files with 5 additions and 1 deletions

View File

@ -139,7 +139,7 @@ module ActiveSupport
result.tr!("_", " ")
result.lstrip!
unless keep_id_suffix
if !keep_id_suffix && lower_case_and_underscored_word.end_with?("_id")
result.delete_suffix!(" id")
end

View File

@ -249,6 +249,8 @@ module InflectorTestCases
UnderscoreToHuman = {
"employee_salary" => "Employee salary",
"employee_id" => "Employee",
"employee id" => "Employee id",
"employee id etc" => "Employee id etc",
"underground" => "Underground",
"_id" => "Id",
"_external_id" => "External"
@ -259,6 +261,8 @@ module InflectorTestCases
"employee_id" => "Employee id",
"employee_id_something_else" => "Employee id something else",
"underground" => "Underground",
"employee id" => "Employee id",
"employee id etc" => "Employee id etc",
"_id" => "Id",
"_external_id" => "External id"
}