public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
camelize(:lower) should always downcase first character. [#696 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Amos King (author)
Fri Aug 22 05:31:13 -0700 2008
lifo (committer)
Fri Aug 22 05:31:13 -0700 2008
commit  381210daa0b8db26be85841b8ccf889d0ef67d75
tree    0f36883b38ebc35bae95e9527d76b9b5f49921cd
parent  89d1c77dd012f087c091e0f23874c582ea4e3703
...
173
174
175
176
 
177
178
179
...
173
174
175
 
176
177
178
179
0
@@ -173,7 +173,7 @@ module ActiveSupport
0
       if first_letter_in_uppercase
0
         lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
0
       else
0
-        lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1]
0
+        lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
0
       end
0
     end
0
 
...
32
33
34
 
 
 
 
35
36
37
...
32
33
34
35
36
37
38
39
40
41
0
@@ -32,6 +32,10 @@ class StringInflectionsTest < Test::Unit::TestCase
0
     end
0
   end
0
 
0
+  def test_camelize_lower
0
+    assert_equal('capital', 'Capital'.camelize(:lower))
0
+  end
0
+
0
   def test_underscore
0
     CamelToUnderscore.each do |camel, underscore|
0
       assert_equal(underscore, camel.underscore)
...
46
47
48
 
 
 
 
49
50
51
...
46
47
48
49
50
51
52
53
54
55
0
@@ -46,6 +46,10 @@ class InflectorTest < Test::Unit::TestCase
0
     end
0
   end
0
 
0
+  def test_camelize_with_lower_downcases_the_first_letter
0
+    assert_equal('capital', ActiveSupport::Inflector.camelize('Capital', false))
0
+  end
0
+
0
   def test_underscore
0
     CamelToUnderscore.each do |camel, underscore|
0
       assert_equal(underscore, ActiveSupport::Inflector.underscore(camel))

Comments