From 7111133371c08d2096cbcffa661860c9ea2c5813 Mon Sep 17 00:00:00 2001 From: Andrey Samsonov Date: Tue, 27 Mar 2012 16:30:08 +0400 Subject: Fixing issue #2492. 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/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index f9940ead58..fc7a37ec07 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -943,6 +943,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", :method => "put") 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 6968bc16a1a609c56cf056cd9cd8f8de251defde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 27 Mar 2012 20:01:59 -0300 Subject: Check if the options hash already exists and merge it with the another hash. Closes #2492 and #5614 --- actionpack/test/template/form_helper_test.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index fc7a37ec07..7eeede7087 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -943,10 +943,25 @@ 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", :method => "put") 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') @@ -955,14 +970,12 @@ class FormHelperTest < ActionView::TestCase end expected = whole_form("/posts/123", "edit_post_123" , "edit_post", :method => "put") 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