aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorYehuda Katz <wycats@Yehuda-Katz.local>2010-01-31 19:17:42 -0800
committerYehuda Katz <wycats@Yehuda-Katz.local>2010-01-31 19:39:13 -0800
commit4cbb9db0a5ff65b0a626a5b043331abefd89e717 (patch)
treea112ce55f5521ff31abf0e4357afcc170fc0a143 /actionpack/test/template
parent1c83fd2eff3fd174e1aba0512aa2dd8ecdadb2c7 (diff)
downloadrails-4cbb9db0a5ff65b0a626a5b043331abefd89e717.tar.gz
rails-4cbb9db0a5ff65b0a626a5b043331abefd89e717.tar.bz2
rails-4cbb9db0a5ff65b0a626a5b043331abefd89e717.zip
For performance reasons, you can no longer call html_safe! on Strings. Instead, all Strings are always not html_safe?. Instead, you can get a SafeBuffer from a String by calling #html_safe, which will SafeBuffer.new(self).
* Additionally, instead of doing concat("</form>".html_safe), you can do safe_concat("</form>"), which will skip both the flag set, and the flag check. * For the first pass, I converted virtually all #html_safe!s to #html_safe, and the tests pass. A further optimization would be to try to use #safe_concat as much as possible, reducing the performance impact if we know up front that a String is safe.
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/erb_util_test.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb2
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb6
-rw-r--r--actionpack/test/template/safe_buffer_test.rb2
-rw-r--r--actionpack/test/template/test_case_test.rb2
5 files changed, 7 insertions, 7 deletions
diff --git a/actionpack/test/template/erb_util_test.rb b/actionpack/test/template/erb_util_test.rb
index fa6b263965..06155b1f30 100644
--- a/actionpack/test/template/erb_util_test.rb
+++ b/actionpack/test/template/erb_util_test.rb
@@ -22,7 +22,7 @@ class ErbUtilTest < Test::Unit::TestCase
end
def test_html_escape_passes_html_escpe_unmodified
- escaped = h("<p>".html_safe!)
+ escaped = h("<p>".html_safe)
assert_equal "<p>", escaped
assert escaped.html_safe?
end
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index caeca9db10..aafc318b76 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1170,7 +1170,7 @@ class FormHelperTest < ActionView::TestCase
(field_helpers - %w(hidden_field)).each do |selector|
src = <<-END_SRC
def #{selector}(field, *args, &proc)
- ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe!
+ ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe
end
END_SRC
class_eval src, __FILE__, __LINE__
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index 553ec44fad..3635c7548e 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -335,19 +335,19 @@ class FormTagHelperTest < ActionView::TestCase
expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
- self.output_buffer = ''
+ self.output_buffer = ''.html_safe
field_set_tag { concat "Hello world!" }
expected = %(<fieldset>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
- self.output_buffer = ''
+ self.output_buffer = ''.html_safe
field_set_tag('') { concat "Hello world!" }
expected = %(<fieldset>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
- self.output_buffer = ''
+ self.output_buffer = ''.html_safe
field_set_tag('', :class => 'format') { concat "Hello world!" }
expected = %(<fieldset class="format">Hello world!</fieldset>)
diff --git a/actionpack/test/template/safe_buffer_test.rb b/actionpack/test/template/safe_buffer_test.rb
index 6a18201d16..41a95e068b 100644
--- a/actionpack/test/template/safe_buffer_test.rb
+++ b/actionpack/test/template/safe_buffer_test.rb
@@ -16,7 +16,7 @@ class SafeBufferTest < ActionView::TestCase
end
test "Should NOT escape a safe value passed to it" do
- @buffer << "<script>".html_safe!
+ @buffer << "<script>".html_safe
assert_equal "<script>", @buffer
end
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index 9a448ce328..be2c6b3108 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -160,7 +160,7 @@ module ActionView
class AssertionsTest < ActionView::TestCase
def render_from_helper
form_tag('/foo') do
- concat render(:text => '<ul><li>foo</li></ul>').html_safe!
+ safe_concat render(:text => '<ul><li>foo</li></ul>')
end
end
helper_method :render_from_helper