Skip to content
Browse files

global variables may not be set depending on the match. fixes #4703

  • Loading branch information...
1 parent ad1b2aa commit ef7fc6ebb3fc7688c11ee664b9748b6c0ed4eb7b @tenderlove tenderlove committed
View
5 activesupport/lib/active_support/inflector/methods.rb
@@ -94,7 +94,10 @@ def humanize(lower_case_and_underscored_word)
result = lower_case_and_underscored_word.to_s.dup
inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
result.gsub!(/_id$/, "")
- result.gsub(/(_)?([a-z\d]*)/i) { "#{$1 && ' '}#{inflections.acronyms[$2] || $2.downcase}" }.gsub(/^\w/) { $&.upcase }
+ result.gsub!(/_/, ' ')
+ result.gsub(/([a-z\d]*)/i) { |match|
+ "#{inflections.acronyms[match] || match.downcase}"
+ }.gsub(/^\w/) { $&.upcase }
end
# Capitalizes all the words and replaces some characters in the string to create
View
4 activesupport/test/safe_buffer_test.rb
@@ -7,6 +7,10 @@ def setup
@buffer = ActiveSupport::SafeBuffer.new
end
+ def test_titleize
+ assert_equal 'Foo', "foo".html_safe.titleize
+ end
+
test "Should look like a string" do
assert @buffer.is_a?(String)
assert_equal "", @buffer

0 comments on commit ef7fc6e

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