Permalink
Browse files

camelize(:lower) should always downcase first character. [#696 state:…

…resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent 89d1c77 commit 381210daa0b8db26be85841b8ccf889d0ef67d75 @adkron adkron committed with lifo Aug 22, 2008
@@ -173,7 +173,7 @@ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
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
@@ -32,6 +32,10 @@ def test_camelize
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)
@@ -46,6 +46,10 @@ def test_camelize
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))

0 comments on commit 381210d

Please sign in to comment.