aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorSantiago Pastorino and José Ignacio Costa <santiago+jose@wyeworks.com>2010-02-03 19:38:58 -0200
committerJeremy Kemper <jeremy@bitsweat.net>2010-02-05 13:25:51 -0800
commit293c53ab3e3795cf0837c0b9225d64b3d906b8aa (patch)
treee4ca84548a8b2e2cbb72a796ab817faa3db72c00 /activesupport/test/core_ext
parentfd567785f4670b31db300324642cf2464025313e (diff)
downloadrails-293c53ab3e3795cf0837c0b9225d64b3d906b8aa.tar.gz
rails-293c53ab3e3795cf0837c0b9225d64b3d906b8aa.tar.bz2
rails-293c53ab3e3795cf0837c0b9225d64b3d906b8aa.zip
Fixed html_safe test cases which weren't testing correctly
[#3845 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb37
1 files changed, 20 insertions, 17 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index ca26f91e8c..d8145d467b 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -335,6 +335,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
@@ -355,17 +360,15 @@ class OutputSafetyTest < ActiveSupport::TestCase
end
test "An object is unsafe by default" do
- klass = Class.new(Object) do
- def to_str
- "other"
- end
- end
+ assert !@object.html_safe?
+ end
- @string.html_safe
- @string << klass.new
+ 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?
+ assert_equal "helloother", string
+ assert string.html_safe?
end
test "Adding a safe string to another safe string returns a safe string" do
@@ -391,9 +394,9 @@ class OutputSafetyTest < ActiveSupport::TestCase
test "Concatting safe onto unsafe yields unsafe" do
@other_string = "other"
- @string.html_safe
- @other_string.concat(@string)
+ string = @string.html_safe
+ @other_string.concat(string)
assert !@other_string.html_safe?
end
@@ -406,17 +409,17 @@ 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
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
@@ -429,9 +432,9 @@ class OutputSafetyTest < ActiveSupport::TestCase
test "Concatting safe onto safe with << yields safe" do
@other_string = "other".html_safe
- @string.html_safe
+ string = @string.html_safe
- @other_string << @string
+ @other_string << string
assert @other_string.html_safe?
end