Steps to reproduce
It looks like ActiveSupport::Inflector.humanize changes its behaviour and was not mentioned in any changelog.
Previously humanize truncate only "_id", but in rails 7 it truncates `" id" which is breaking change.
The change was introduced at 8e0f88d
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
if ENV['RAILS_VERSION']
gem "activesupport", ENV['RAILS_VERSION']
else
gem "activesupport"
end
end
require "active_support"
require "active_support/core_ext/object/blank"
require "minitest/autorun"
class BugTest < Minitest::Test
def test_stuff
actual = ActiveSupport::Inflector.humanize("caller id")
assert_equal 'Caller id', actual
end
end
Expected behaviour
"caller id" string should be humanized to "Caller id" (like it being done since rails 3)
Actual behaviour
senid@senid-laptop:~/projects/didww/didww-api-3$ RAILS_VERSION="~> 7.0" ruby bug_reports/test_rails_humanize_bug.rb
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using minitest 5.18.0
Using concurrent-ruby 1.2.2
Using bundler 2.3.11
Using i18n 1.13.0
Using tzinfo 2.0.6
Using activesupport 7.0.5
Run options: --seed 10373
# Running:
F
Finished in 0.000903s, 1107.5939 runs/s, 1107.5939 assertions/s.
1) Failure:
BugTest#test_stuff [bug_reports/test_rails_humanize_bug.rb:24]:
Expected: "Caller id"
Actual: "Caller"
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
And this bug report test passes in Rails 6.1+
`"caller id"` is humanized to `"Caller"`
$ RAILS_VERSION="~> 6.1" ruby bug_reports/test_rails_humanize_bug.rb
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using bundler 2.3.11
Using zeitwerk 2.6.8
Using minitest 5.18.0
Using concurrent-ruby 1.2.2
Using i18n 1.13.0
Using tzinfo 2.0.6
Using activesupport 6.1.7.3 (was 7.0.5)
Run options: --seed 12928
# Running:
.
Finished in 0.000873s, 1145.0426 runs/s, 1145.0426 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
System configuration
Rails version: 7.0.5
Ruby version: 3.1.2
Steps to reproduce
It looks like
ActiveSupport::Inflector.humanizechanges its behaviour and was not mentioned in any changelog.Previously
humanizetruncate only"_id", but in rails 7 it truncates `" id" which is breaking change.The change was introduced at 8e0f88d
Expected behaviour
"caller id"string should be humanized to"Caller id"(like it being done since rails 3)Actual behaviour
And this bug report test passes in Rails 6.1+
System configuration
Rails version: 7.0.5
Ruby version: 3.1.2