aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/template_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-11-16 00:33:14 -0800
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-16 09:59:15 -0200
commit666a7e34f553cef4c8878362eafc79c7e3f310c3 (patch)
tree85ed6e0dd3a97e1d70ecce0b13e528c034f98046 /actionpack/test/template/template_test.rb
parentf2a98a9243a3eb078efa11b901a6b6446e89717e (diff)
downloadrails-666a7e34f553cef4c8878362eafc79c7e3f310c3.tar.gz
rails-666a7e34f553cef4c8878362eafc79c7e3f310c3.tar.bz2
rails-666a7e34f553cef4c8878362eafc79c7e3f310c3.zip
Merge pull request #8235 from tilsammans/dont_escape_actionmailer_when_plaintext
Introduce `ActionView::Template::Handlers::ERB.escape_whitelist` Conflicts: actionpack/CHANGELOG.md actionpack/test/template/template_test.rb
Diffstat (limited to 'actionpack/test/template/template_test.rb')
-rw-r--r--actionpack/test/template/template_test.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb
index 5880eb2bd4..aa7f5b31fc 100644
--- a/actionpack/test/template/template_test.rb
+++ b/actionpack/test/template/template_test.rb
@@ -25,6 +25,10 @@ class TestERBTemplate < ActiveSupport::TestCase
"Hello"
end
+ def apostrophe
+ "l'apostrophe"
+ end
+
def partial
ActionView::Template.new(
"<%= @virtual_path %>",
@@ -47,7 +51,7 @@ class TestERBTemplate < ActiveSupport::TestCase
end
end
- def new_template(body = "<%= hello %>", details = {})
+ def new_template(body = "<%= hello %>", details = { :format => :html })
ActionView::Template.new(body, "hello template", ERBHandler, {:virtual_path => "hello"}.merge!(details))
end
@@ -64,6 +68,16 @@ class TestERBTemplate < ActiveSupport::TestCase
assert_equal "Hello", render
end
+ def test_basic_template_does_html_escape
+ @template = new_template("<%= apostrophe %>")
+ assert_equal "l&#x27;apostrophe", render
+ end
+
+ def test_text_template_does_not_html_escape
+ @template = new_template("<%= apostrophe %>", :format => :text)
+ assert_equal "l'apostrophe", render
+ end
+
def test_template_loses_its_source_after_rendering
@template = new_template
render