Skip to content

Commit

Permalink
global variables may not be set depending on the match. fixes #4703
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jan 26, 2012
1 parent 2809375 commit 7ba3ecc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion activesupport/lib/active_support/inflector/methods.rb
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions activesupport/test/safe_buffer_test.rb
Expand Up @@ -12,6 +12,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
Expand Down

0 comments on commit 7ba3ecc

Please sign in to comment.