aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2017-11-06 14:46:42 +0000
committerAndrew White <andrew.white@unboxed.co>2017-11-06 14:47:47 +0000
commit0ddde0a8fca6a0ca3158e3329713959acd65605d (patch)
treeac41672e93e2ed1d3ae26dd3b427e688bc41c6b3 /activesupport/test
parent7d1d6c4c0bde7364aeb66c22514a78bd9f8f1ecd (diff)
downloadrails-0ddde0a8fca6a0ca3158e3329713959acd65605d.tar.gz
rails-0ddde0a8fca6a0ca3158e3329713959acd65605d.tar.bz2
rails-0ddde0a8fca6a0ca3158e3329713959acd65605d.zip
Fix acronym support in `humanize`
Acronym inflections are stored with lowercase keys in the hash but the match wasn't being lowercased before being looked up in the hash. This shouldn't have any performance impact because before it would fail to find the acronym and perform the `downcase` operation anyway. Fixes #31052.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/inflector_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index eeec0ab1a5..6cc1039d8e 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -356,6 +356,19 @@ class InflectorTest < ActiveSupport::TestCase
assert_equal("Col rpted bugs", ActiveSupport::Inflector.humanize("COL_rpted_bugs"))
end
+ def test_humanize_with_acronyms
+ ActiveSupport::Inflector.inflections do |inflect|
+ inflect.acronym "LAX"
+ inflect.acronym "SFO"
+ end
+ assert_equal("LAX roundtrip to SFO", ActiveSupport::Inflector.humanize("LAX ROUNDTRIP TO SFO"))
+ assert_equal("LAX roundtrip to SFO", ActiveSupport::Inflector.humanize("LAX ROUNDTRIP TO SFO", capitalize: false))
+ assert_equal("LAX roundtrip to SFO", ActiveSupport::Inflector.humanize("lax roundtrip to sfo"))
+ assert_equal("LAX roundtrip to SFO", ActiveSupport::Inflector.humanize("lax roundtrip to sfo", capitalize: false))
+ assert_equal("LAX roundtrip to SFO", ActiveSupport::Inflector.humanize("Lax Roundtrip To Sfo"))
+ assert_equal("LAX roundtrip to SFO", ActiveSupport::Inflector.humanize("Lax Roundtrip To Sfo", capitalize: false))
+ end
+
def test_constantize
run_constantize_tests_on do |string|
ActiveSupport::Inflector.constantize(string)