diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 5 | ||||
-rw-r--r-- | activesupport/test/safe_buffer_test.rb | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index c245b5b53c..9b0f0e859a 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -94,7 +94,10 @@ module ActiveSupport 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 diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb index 2fde07995b..bdde5141a9 100644 --- a/activesupport/test/safe_buffer_test.rb +++ b/activesupport/test/safe_buffer_test.rb @@ -7,6 +7,10 @@ class SafeBufferTest < ActiveSupport::TestCase @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 |