aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorPaul Hieromnimon <paul.hieromnimon@gmail.com>2011-02-10 20:38:14 +0800
committerJosé Valim <jose.valim@gmail.com>2011-02-10 23:47:53 +0800
commitf7221f5c7571da50d4d0199c0a7502cc7cd82b6e (patch)
tree9b9f3d9579a848a30b23b4c5b7c3994f10600201 /activesupport/test/core_ext
parentc560c8b2ba2af2ff1942e40b8eff8287354bf7d8 (diff)
downloadrails-f7221f5c7571da50d4d0199c0a7502cc7cd82b6e.tar.gz
rails-f7221f5c7571da50d4d0199c0a7502cc7cd82b6e.tar.bz2
rails-f7221f5c7571da50d4d0199c0a7502cc7cd82b6e.zip
Initial html_safe implemention for Array
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index bb865cae91..41a23641d4 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -434,6 +434,50 @@ class OutputSafetyTest < ActiveSupport::TestCase
assert string.html_safe?
end
+ test "Joining safe elements without a separator is safe" do
+ array = 5.times.collect {"some string".html_safe}
+ assert array.join.html_safe?
+ end
+
+ test "Joining safe elements with a safe separator is safe" do
+ array = 5.times.collect {"some string".html_safe}
+ assert array.join("-".html_safe).html_safe?
+ end
+
+ test "Joining safe elements with an unsafe separator is unsafe" do
+ array = 5.times.collect {"some string".html_safe}
+ assert_false array.join("-").html_safe?
+ end
+
+ test "Joining is unsafe if any element is unsafe even with a safe separator" do
+ array = 5.times.collect {"some string".html_safe}
+ array << "some string"
+ assert_false array.join("-".html_safe).html_safe?
+ end
+
+ test "Joining is unsafe if any element is unsafe and no separator is given" do
+ array = 5.times.collect {"some string".html_safe}
+ array << "some string"
+ assert_false array.join.html_safe?
+ end
+
+ test "Joining is unsafe if any element is unsafe and the separator is unsafe" do
+ array = 5.times.collect {"some string".html_safe}
+ array << "some string"
+ assert_false array.join("-").html_safe?
+ end
+
+ test "Array is safe if all elements are safe" do
+ array = 5.times.collect { "some string".html_safe }
+ assert array.html_safe?
+ end
+
+ test "Array is unsafe if any element is unsafe" do
+ array = 5.times.collect { "some string".html_safe }
+ array << "some string"
+ assert_false array.html_safe?
+ end
+
test 'emits normal string yaml' do
assert_equal 'foo'.to_yaml, 'foo'.html_safe.to_yaml(:foo => 1)
end