Skip to content
This repository
Browse code

OutputBuffer#to_yaml should return string yaml, not some custom class…

… dump
  • Loading branch information...
commit 1f6c5677ad18a2d49866100b043b82bd030875d4 1 parent 698312d
Jeremy Kemper authored March 11, 2010
4  activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -88,6 +88,10 @@ def html_safe
88 88
     def to_s
89 89
       self
90 90
     end
  91
+
  92
+    def to_yaml
  93
+      "".replace(self).to_yaml
  94
+    end
91 95
   end
92 96
 end
93 97
 
4  activesupport/test/core_ext/string_ext_test.rb
@@ -444,6 +444,10 @@ def to_s
444 444
     assert_equal "hello".concat(13), string
445 445
     assert string.html_safe?
446 446
   end
  447
+
  448
+  test 'emits normal string yaml' do
  449
+    assert_equal 'foo'.to_yaml, 'foo'.html_safe.to_yaml
  450
+  end
447 451
 end
448 452
 
449 453
 class StringExcludeTest < ActiveSupport::TestCase

0 notes on commit 1f6c567

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