From 213a8e2f99eddf8fd52d0fb695427c4f6b46cf85 Mon Sep 17 00:00:00 2001 From: Rune Botten Date: Thu, 17 Jul 2008 18:38:23 +0200 Subject: [PATCH] tags with type hidden get wrapped in divs with class rails-hidden-inputs --- actionpack/lib/action_view/helpers/tag_helper.rb | 2 ++ .../controller/request_forgery_protection_test.rb | 2 +- .../test/template/active_record_helper_test.rb | 2 +- actionpack/test/template/form_helper_test.rb | 10 +++++----- actionpack/test/template/form_tag_helper_test.rb | 6 +++--- actionpack/test/template/prototype_helper_test.rb | 6 +++--- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index de08672..e9ec81c 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -124,7 +124,9 @@ module ActionView end end + # Upon content containing +type+ set to +hidden+, content will be wrapped in element with class +rails-hidden-inputs+ def content_tag_string(name, content, options, escape = true) + options[:class] = 'rails-hidden-inputs' if content =~ /type=\"hidden\"/ tag_options = tag_options(options, escape) if options "<#{name}#{tag_options}>#{content}" end diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index f7adaa7..ffaeacd 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -79,7 +79,7 @@ module RequestForgeryProtectionTests def test_should_render_form_with_token_tag get :index - assert_select 'form>div>input[name=?][value=?]', 'authenticity_token', @token + assert_select 'form>div[class=?]>input[name=?][value=?]', 'rails-hidden-inputs', 'authenticity_token', @token end def test_should_render_button_to_with_token_tag diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb index dfc30e6..5db23fa 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -146,7 +146,7 @@ class ActiveRecordHelperTest < ActionView::TestCase @request_forgery_protection_token = 'authenticity_token' @form_authenticity_token = '123' assert_dom_equal( - %(


\n


), + %(


\n


), form("post") ) end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 39649c3..5059fd5 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -367,7 +367,7 @@ class FormHelperTest < ActionView::TestCase expected = "
" + - "
" + + "
" + "" + "" + "" + @@ -762,7 +762,7 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_existing_object form_for(@post) do |f| end - expected = "
" + expected = "
" assert_equal expected, output_buffer end @@ -783,7 +783,7 @@ class FormHelperTest < ActionView::TestCase form_for([@post, @comment]) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end @@ -802,7 +802,7 @@ class FormHelperTest < ActionView::TestCase form_for([:admin, @post, @comment]) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end @@ -818,7 +818,7 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_existing_object_and_custom_url form_for(@post, :url => "/super_posts") do |f| end - expected = "
" + expected = "
" assert_equal expected, output_buffer end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 4e4102a..abd535d 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -32,13 +32,13 @@ class FormTagHelperTest < ActionView::TestCase def test_form_tag_with_method_put actual = form_tag({}, { :method => :put }) - expected = %(
) + expected = %(
) assert_dom_equal expected, actual end def test_form_tag_with_method_delete actual = form_tag({}, { :method => :delete }) - expected = %(
) + expected = %(
) assert_dom_equal expected, actual end @@ -54,7 +54,7 @@ class FormTagHelperTest < ActionView::TestCase __in_erb_template = '' form_tag("http://example.com", :method => :put) { concat "Hello world!" } - expected = %(
Hello world!
) + expected = %(
Hello world!
) assert_dom_equal expected, output_buffer end diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index 92cc857..f27397d 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -113,7 +113,7 @@ class PrototypeHelperTest < PrototypeHelperBaseTest end def test_form_remote_tag_with_method - assert_dom_equal %(
), + assert_dom_equal %(
), form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast }, :html => { :method => :put }) end @@ -141,7 +141,7 @@ class PrototypeHelperTest < PrototypeHelperBaseTest @record.save remote_form_for(@record) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end @@ -157,7 +157,7 @@ class PrototypeHelperTest < PrototypeHelperBaseTest @article.save remote_form_for([@author, @article]) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end -- 1.5.6.2