From 6df507e884baa8566b685bb1c555e42185570160 Mon Sep 17 00:00:00 2001 From: Pavel Pravosud Date: Mon, 31 Mar 2014 22:33:53 -0400 Subject: Make AS::SafeBuffer#prepend act like String#prepend Make `#prepend` method modify instance in-place and return self instead of just returning modified value. That is exactly what `#prepend!` method was doing previously, so it's deprecated from now on. --- activesupport/test/core_ext/string_ext_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 072b970a2d..4a7c2dac39 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -4,6 +4,7 @@ require 'abstract_unit' require 'inflector_test_cases' require 'constantize_test_cases' +require 'active_support/deprecation/reporting' require 'active_support/inflector' require 'active_support/core_ext/string' require 'active_support/time' @@ -608,6 +609,27 @@ class OutputSafetyTest < ActiveSupport::TestCase assert !@other_combination.html_safe? end + test "Prepending safe onto unsafe yields unsafe" do + @string.prepend "other".html_safe + assert !@string.html_safe? + assert_equal @string, "otherhello" + end + + test "Prepending unsafe onto safe yields escaped safe" do + other = "other".html_safe + other.prepend "" + assert other.html_safe? + assert_equal other, "<foo>other" + end + + test "Deprecated #prepend! method is still present" do + ActiveSupport::Deprecation.silence do + other = "other".html_safe + other.prepend! "" + assert_equal other, "<foo>other" + end + end + test "Concatting safe onto unsafe yields unsafe" do @other_string = "other" -- cgit v1.2.3