diff options
author | Amos King <amos.l.king@gmail.com> | 2008-08-22 13:31:13 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-08-22 13:31:13 +0100 |
commit | 381210daa0b8db26be85841b8ccf889d0ef67d75 (patch) | |
tree | 0f36883b38ebc35bae95e9527d76b9b5f49921cd /activesupport | |
parent | 89d1c77dd012f087c091e0f23874c582ea4e3703 (diff) | |
download | rails-381210daa0b8db26be85841b8ccf889d0ef67d75.tar.gz rails-381210daa0b8db26be85841b8ccf889d0ef67d75.tar.bz2 rails-381210daa0b8db26be85841b8ccf889d0ef67d75.zip |
camelize(:lower) should always downcase first character. [#696 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/inflector.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 4 | ||||
-rw-r--r-- | activesupport/test/inflector_test.rb | 4 |
3 files changed, 9 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index c2738b39fc..1e189465bd 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -173,7 +173,7 @@ module ActiveSupport if first_letter_in_uppercase lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } else - lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1] + lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1] end end diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 19a30f1730..c9f959ef32 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -32,6 +32,10 @@ class StringInflectionsTest < Test::Unit::TestCase end end + def test_camelize_lower + assert_equal('capital', 'Capital'.camelize(:lower)) + end + def test_underscore CamelToUnderscore.each do |camel, underscore| assert_equal(underscore, camel.underscore) diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 6c0c14e866..b2fad4a9bc 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -46,6 +46,10 @@ class InflectorTest < Test::Unit::TestCase end end + def test_camelize_with_lower_downcases_the_first_letter + assert_equal('capital', ActiveSupport::Inflector.camelize('Capital', false)) + end + def test_underscore CamelToUnderscore.each do |camel, underscore| assert_equal(underscore, ActiveSupport::Inflector.underscore(camel)) |