From 06388b07791a24e9d3351a74bfdf23809bb1e69b Mon Sep 17 00:00:00 2001 From: Takayuki Matsubara Date: Sat, 6 Jul 2013 01:01:51 +0900 Subject: Added an `enforce_utf8` hash option for `form_tag` method Control to output a hidden input tag with name `utf8` without monkey patching Before: form_tag # => '
....
' After: form_tag # => '
....
' form_tag({}, { :enforce_utf8 => false }) # => '
....
' --- actionview/test/template/form_tag_helper_test.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'actionview/test/template') diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 70fc6a588b..22bf438a56 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -12,9 +12,10 @@ class FormTagHelperTest < ActionView::TestCase def hidden_fields(options = {}) method = options[:method] + enforce_utf8 = options.fetch(:enforce_utf8, true) txt = %{
} - txt << %{} + txt << %{} if enforce_utf8 if method && !%w(get post).include?(method.to_s) txt << %{} end @@ -110,6 +111,20 @@ class FormTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end + def test_form_tag_enforce_utf8_true + actual = form_tag({}, { :enforce_utf8 => true }) + expected = whole_form("http://www.example.com", :enforce_utf8 => true) + assert_dom_equal expected, actual + assert actual.html_safe? + end + + def test_form_tag_enforce_utf8_false + actual = form_tag({}, { :enforce_utf8 => false }) + expected = whole_form("http://www.example.com", :enforce_utf8 => false) + assert_dom_equal expected, actual + assert actual.html_safe? + end + def test_form_tag_with_block_in_erb output_buffer = render_erb("<%= form_tag('http://www.example.com') do %>Hello world!<% end %>") -- cgit v1.2.3