Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ensure Inflector.camelize works with symbols [#2856 state:resolved]
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
  • Loading branch information
Yehuda Katz + Carl Lerche committed Jul 1, 2009
1 parent 7583a24 commit 882dd4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/inflector.rb
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions activesupport/test/inflector_test.rb
Expand Up @@ -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}
Expand Down
7 changes: 7 additions & 0 deletions activesupport/test/inflector_test_cases.rb
Expand Up @@ -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",
Expand Down

2 comments on commit 882dd4e

@calavera
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't I appear as author?? The patch is well formed and my name is in it.

@calavera
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.