diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-03-27 16:15:11 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-03-27 16:15:11 -0700 |
commit | da5f65676e4e6f9ac38a3bd0003cf3b1308ff0ea (patch) | |
tree | edd0cf871e86294dfbe12afe1f45c166e3501b3a /actionpack/test | |
parent | 33164c8f1479b826a044ab90f4cc2439666e4b16 (diff) | |
parent | 32763a82444ba5eb711ec0e5d6380818e5f2695d (diff) | |
download | rails-da5f65676e4e6f9ac38a3bd0003cf3b1308ff0ea.tar.gz rails-da5f65676e4e6f9ac38a3bd0003cf3b1308ff0ea.tar.bz2 rails-da5f65676e4e6f9ac38a3bd0003cf3b1308ff0ea.zip |
Merge pull request #5621 from rafaelfranca/fix-2492-master
Fix label_tag to merge the options hash with the object hash
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index c5a32635f8..7b684822fc 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1046,6 +1046,40 @@ 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 + "<div class='field_with_errors'><label for='post_author_name' class='label'>Author name</label></div>" + + "<div class='field_with_errors'><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 + end + + def test_form_for_label_error_wrapping_without_conventional_instance_variable + post = remove_instance_variable :@post + + 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='field_with_errors'><label for='post_author_name' class='label'>Author name</label></div>" + + "<div class='field_with_errors'><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 + end + def test_form_for_with_namespace form_for(@post, :namespace => 'namespace') do |f| concat f.text_field(:title) |