From 71b6f76543686a9ffdc3d6f9045de195ce7d7272 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 19 May 2005 19:15:30 +0000 Subject: Fixed the Inflector to underscore strings containing numbers, so Area51Controller becomes area51_controller #1176 [Nicholas Seckar] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1330 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/CHANGELOG | 2 ++ activesupport/lib/active_support/inflector.rb | 2 +- activesupport/test/inflector_test.rb | 3 ++- activesupport/test/loading_module_tests.rb | 7 ++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 1cdc0b08c6..0727790c47 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed the Inflector to underscore strings containing numbers, so Area51Controller becomes area51_controller #1176 [Nicholas Seckar] + * Fixed that HashWithIndifferentAccess stringified all keys including symbols, ints, objects, and arrays #1162 [Nicholas Seckar] * Fixed Time#last_year to go back in time, not forward #1278 [fabien@odilat.com] diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 5d885c62bf..2f2b37f52a 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -24,7 +24,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])([A-Z])/,'\1_\2').downcase + camel_cased_word.to_s.gsub(/::/, '/').gsub(/([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 7694911605..670ab83317 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -66,7 +66,8 @@ class InflectorTest < Test::Unit::TestCase CamelToUnderscore = { "Product" => "product", "SpecialGuest" => "special_guest", - "ApplicationController" => "application_controller" + "ApplicationController" => "application_controller", + "Area51Controller" => "area51_controller" } CamelWithModuleToUnderscoreWithSlash = { diff --git a/activesupport/test/loading_module_tests.rb b/activesupport/test/loading_module_tests.rb index 01361fae1e..22fc00db7e 100644 --- a/activesupport/test/loading_module_tests.rb +++ b/activesupport/test/loading_module_tests.rb @@ -92,6 +92,11 @@ class LoadingModuleTests < Test::Unit::TestCase assert_equal :outer, @loading_module::ContentController.new.identifier assert @loading_module::ContentController.object_id != @loading_module::Admin::ContentController.object_id end + + def test_access_to_controller_with_numbers + assert @loading_module.const_available?(:Area51Controller) + assert_not_nil @loading_module::Area51Controller + end end class LoadingModuleMultiPathTests < Test::Unit::TestCase @@ -116,4 +121,4 @@ class LoadingModuleMultiPathTests < Test::Unit::TestCase assert @loading_module::List.const_load!(:ListController) assert_kind_of Class, @loading_module::List::ListController end -end \ No newline at end of file +end -- cgit v1.2.3