aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb4
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb4
2 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index 567ba00b0d..c55b471986 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -88,6 +88,10 @@ module ActiveSupport #:nodoc:
def to_s
self
end
+
+ def to_yaml
+ "".replace(self).to_yaml
+ end
end
end
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index d8145d467b..6b296fb757 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -444,6 +444,10 @@ class OutputSafetyTest < ActiveSupport::TestCase
assert_equal "hello".concat(13), string
assert string.html_safe?
end
+
+ test 'emits normal string yaml' do
+ assert_equal 'foo'.to_yaml, 'foo'.html_safe.to_yaml
+ end
end
class StringExcludeTest < ActiveSupport::TestCase