diff options
author | Andrey Samsonov <andrey.samsonov@gmail.com> | 2012-03-27 17:12:07 +0400 |
---|---|---|
committer | Andrey Samsonov <andrey.samsonov@gmail.com> | 2012-03-27 17:12:07 +0400 |
commit | 6ce0a6de7e698dabcef10b8ebc855b47555d540b (patch) | |
tree | 3d0974ef5eefbd164b760fde83e1bed12cebe1df /actionpack/test | |
parent | 67b2404cf9b2c7e0f86bf0294571ef97391a6dcd (diff) | |
download | rails-6ce0a6de7e698dabcef10b8ebc855b47555d540b.tar.gz rails-6ce0a6de7e698dabcef10b8ebc855b47555d540b.tar.bz2 rails-6ce0a6de7e698dabcef10b8ebc855b47555d540b.zip |
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
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
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| "<div class='error'>#{html_tag}</div>".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 + "<div class='error'><label for='post_author_name' class='label'>Author name</label></div>" + + "<div class='error'><input name='post[author_name]' type='text' id='post_author_name' value='' /></div>" + + "<input name='commit' type='submit' value='Create post' />" + 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) |