Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ensure Inflector.camelize works with symbols [#2856 state:resolved]

Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
  • Loading branch information...
commit 882dd4e6054470ee56c46ab1432861952c81b633 1 parent 7583a24
Yehuda Katz + Carl Lerche authored
View
2  activesupport/lib/active_support/inflector.rb
@@ -183,7 +183,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.downcase + camelize(lower_case_and_underscored_word)[1..-1]
+ lower_case_and_underscored_word.to_s.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
end
end
View
6 activesupport/test/inflector_test.rb
@@ -202,6 +202,12 @@ def test_underscore_to_lower_camel
end
end
+ def test_symbol_to_lower_camel
+ SymbolToLowerCamel.each do |symbol, lower_camel|
+ assert_equal(lower_camel, ActiveSupport::Inflector.camelize(symbol, false))
+ end
+ end
+
%w{plurals singulars uncountables humans}.each do |inflection_type|
class_eval "
def test_clear_#{inflection_type}
View
7 activesupport/test/inflector_test_cases.rb
@@ -117,6 +117,13 @@ module InflectorTestCases
"area51_controller" => "area51Controller"
}
+ SymbolToLowerCamel = {
+ :product => 'product',
+ :special_guest => 'specialGuest',
+ :application_controller => 'applicationController',
+ :area51_controller => 'area51Controller'
+ }
+
CamelToUnderscoreWithoutReverse = {
"HTMLTidy" => "html_tidy",
"HTMLTidyGenerator" => "html_tidy_generator",

2 comments on commit 882dd4e

Please sign in to comment.
Something went wrong with that request. Please try again.