diff options
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/inflector.rb | 2 | ||||
-rw-r--r-- | activesupport/test/inflector_test.rb | 15 |
3 files changed, 14 insertions, 5 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index cf0cfbc826..62686e8e75 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed Inflector.underscore for use with acronyms, so HTML becomes html instead of htm_l #2173 [k@v2studio.com] + * Fixed dependencies related infinite recursion bug when a controller file does not contain a controller class. Closes #1760. [rcolli2@tampabay.rr.com] * Fixed inflections for status, quiz, move #2056 [deirdre@deirdre.net] diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 087c883b0b..281ea3f4b9 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -114,7 +114,7 @@ module Inflector end def underscore(camel_cased_word) - camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase + camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase end def humanize(lower_case_and_underscored_word) diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 620ae6f78e..0f398df8ff 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -109,7 +109,14 @@ class InflectorTest < Test::Unit::TestCase "Product" => "product", "SpecialGuest" => "special_guest", "ApplicationController" => "application_controller", - "Area51Controller" => "area51_controller" + "Area51Controller" => "area51_controller", + } + + CamelToUnderscoreWithoutReverse = { + "HTMLTidy" => "html_tidy", + "HTMLTidyGenerator" => "html_tidy_generator", + "FreeBSD" => "free_bsd", + "HTML" => "html", } CamelWithModuleToUnderscoreWithSlash = { @@ -199,9 +206,9 @@ class InflectorTest < Test::Unit::TestCase CamelToUnderscore.each do |camel, underscore| assert_equal(underscore, Inflector.underscore(camel)) end - - assert_equal "html_tidy", Inflector.underscore("HTMLTidy") - assert_equal "html_tidy_generator", Inflector.underscore("HTMLTidyGenerator") + CamelToUnderscoreWithoutReverse.each do |camel, underscore| + assert_equal(underscore, Inflector.underscore(camel)) + end end def test_camelize_with_module |