diff options
author | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-02-10 16:45:39 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-02-10 16:51:30 +0100 |
commit | 1814298d7590988d354955efdb0bc495b359293b (patch) | |
tree | 8592b94b8ba65f2b325466ef933cb4dc7950b9f8 /actionpack/test/template | |
parent | 89a5f1463d7e9546ed7a0cf482afea99ba2040e7 (diff) | |
download | rails-1814298d7590988d354955efdb0bc495b359293b.tar.gz rails-1814298d7590988d354955efdb0bc495b359293b.tar.bz2 rails-1814298d7590988d354955efdb0bc495b359293b.zip |
Removed Array#safe_join in AS core_ext and moved it to a view helper with the same same. This also changes how safe_join works, if items or the separator are not html_safe they are html_escape'd, a html_safe string is always returned.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/output_safety_helper_test.rb | 30 | ||||
-rw-r--r-- | actionpack/test/template/raw_output_helper_test.rb | 21 |
2 files changed, 30 insertions, 21 deletions
diff --git a/actionpack/test/template/output_safety_helper_test.rb b/actionpack/test/template/output_safety_helper_test.rb new file mode 100644 index 0000000000..fc127c24e9 --- /dev/null +++ b/actionpack/test/template/output_safety_helper_test.rb @@ -0,0 +1,30 @@ +require 'abstract_unit' +require 'testing_sandbox' + +class OutputSafetyHelperTest < ActionView::TestCase + tests ActionView::Helpers::OutputSafetyHelper + include TestingSandbox + + def setup + @string = "hello" + end + + test "raw returns the safe string" do + result = raw(@string) + assert_equal @string, result + assert result.html_safe? + end + + test "raw handles nil values correctly" do + assert_equal "", raw(nil) + end + + test "safe_join should html_escape any items, including the separator, if they are not html_safe" do + joined = safe_join(["<p>foo</p>".html_safe, "<p>bar</p>"], "<br />") + assert_equal "<p>foo</p><br /><p>bar</p>", joined + + joined = safe_join(["<p>foo</p>".html_safe, "<p>bar</p>".html_safe], "<br />".html_safe) + assert_equal "<p>foo</p><br /><p>bar</p>", joined + end + +end
\ No newline at end of file diff --git a/actionpack/test/template/raw_output_helper_test.rb b/actionpack/test/template/raw_output_helper_test.rb deleted file mode 100644 index 598aa5b1d8..0000000000 --- a/actionpack/test/template/raw_output_helper_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'abstract_unit' -require 'testing_sandbox' - -class RawOutputHelperTest < ActionView::TestCase - tests ActionView::Helpers::RawOutputHelper - include TestingSandbox - - def setup - @string = "hello" - end - - test "raw returns the safe string" do - result = raw(@string) - assert_equal @string, result - assert result.html_safe? - end - - test "raw handles nil values correctly" do - assert_equal "", raw(nil) - end -end
\ No newline at end of file |