From fe6787c1e0aff9af42b810cbdaeabca8baa7c100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Pastorino=20and=20Jos=C3=A9=20Ignacio=20Costa?= Date: Fri, 5 Feb 2010 19:47:22 -0200 Subject: [PATCH] Fixed html_safe test cases which weren't testing correctly backport from 3.0 --- activesupport/test/core_ext/string_ext_test.rb | 33 +++++++++++++++++++---- 1 files changed, 27 insertions(+), 6 deletions(-) diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 5a369dd..e2e6cbb 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -285,6 +285,11 @@ end class OutputSafetyTest < ActiveSupport::TestCase def setup @string = "hello" + @object = Class.new(Object) do + def to_s + "other" + end + end.new end test "A string is unsafe by default" do @@ -313,6 +318,22 @@ class OutputSafetyTest < ActiveSupport::TestCase assert_equal @string, @string.html_safe end + test "A fixnum is safe by default" do + assert 5.html_safe? + end + + test "An object is unsafe by default" do + assert !@object.html_safe? + end + + test "Adding an object to a safe string returns a safe string" do + string = @string.html_safe + string << @object + + assert_equal "helloother", string + assert string.html_safe? + end + test "Adding a safe string to another safe string returns a safe string using html_safe!" do assert_deprecated do @other_string = "other".html_safe! @@ -371,9 +392,9 @@ class OutputSafetyTest < ActiveSupport::TestCase test "Concatting safe onto unsafe yields unsafe" do @other_string = "other" - @string.html_safe + string = @string.html_safe - @other_string.concat(@string) + @other_string.concat(string) assert !@other_string.html_safe? end @@ -405,9 +426,9 @@ class OutputSafetyTest < ActiveSupport::TestCase test "Concatting safe onto safe yields safe" do @other_string = "other".html_safe - @string.html_safe + string = @string.html_safe - @other_string.concat(@string) + @other_string.concat(string) assert @other_string.html_safe? end @@ -423,9 +444,9 @@ class OutputSafetyTest < ActiveSupport::TestCase test "Concatting safe onto unsafe with << yields unsafe" do @other_string = "other" - @string.html_safe + string = @string.html_safe - @other_string << @string + @other_string << string assert !@other_string.html_safe? end -- 1.6.5