From 6ce0a6de7e698dabcef10b8ebc855b47555d540b Mon Sep 17 00:00:00 2001 From: Andrey Samsonov Date: Tue, 27 Mar 2012 17:12:07 +0400 Subject: Fixing issue #2492 for master branch. ActionView::Base.field_error_proc doesn't call for label. objectify_options method should be applied to the proper options arg. See explanation and example of the bug - https://github.com/kryzhovnik/rails_field_error_proc_bug_example --- actionpack/test/template/form_helper_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index c5a32635f8..2fa7c48a18 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1046,6 +1046,28 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_label_error_wrapping_without_conventional_instance_variable + post = remove_instance_variable :@post + default_field_error_proc = ActionView::Base.field_error_proc + ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "
#{html_tag}
".html_safe } + + form_for(post) do |f| + concat f.label(:author_name, :class => 'label') + concat f.text_field(:author_name) + concat f.submit('Create post') + end + + expected = whole_form('/posts/123', 'edit_post_123' , 'edit_post', 'patch') do + "
" + + "
" + + "" + end + + assert_dom_equal expected, output_buffer + ensure + ActionView::Base.field_error_proc = default_field_error_proc + end + def test_form_for_with_namespace form_for(@post, :namespace => 'namespace') do |f| concat f.text_field(:title) -- cgit v1.2.3 From 32763a82444ba5eb711ec0e5d6380818e5f2695d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 27 Mar 2012 19:45:51 -0300 Subject: Check if the options hash already exists and merge it with the another hash. Closes #2492 and #5615 --- actionpack/test/template/form_helper_test.rb | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 2fa7c48a18..7b684822fc 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1046,10 +1046,24 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_label_error_wrapping + form_for(@post) do |f| + concat f.label(:author_name, :class => 'label') + concat f.text_field(:author_name) + concat f.submit('Create post') + end + + expected = whole_form('/posts/123', 'edit_post_123' , 'edit_post', 'patch') do + "
" + + "
" + + "" + end + + assert_dom_equal expected, output_buffer + end + def test_form_for_label_error_wrapping_without_conventional_instance_variable post = remove_instance_variable :@post - default_field_error_proc = ActionView::Base.field_error_proc - ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "
#{html_tag}
".html_safe } form_for(post) do |f| concat f.label(:author_name, :class => 'label') @@ -1058,14 +1072,12 @@ class FormHelperTest < ActionView::TestCase end expected = whole_form('/posts/123', 'edit_post_123' , 'edit_post', 'patch') do - "
" + - "
" + + "
" + + "
" + "" end assert_dom_equal expected, output_buffer - ensure - ActionView::Base.field_error_proc = default_field_error_proc end def test_form_for_with_namespace -- cgit v1.2.3