diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-03-27 16:15:21 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-03-27 16:15:21 -0700 |
commit | 460d2c7c28928ab0d880675c3a7a74e81605e835 (patch) | |
tree | 2083c7e91e7e34ad28441b255744262418ba37e3 /actionpack/test | |
parent | d82e4c80a820280c8bb9957bd86453d8fea49384 (diff) | |
parent | 6968bc16a1a609c56cf056cd9cd8f8de251defde (diff) | |
download | rails-460d2c7c28928ab0d880675c3a7a74e81605e835.tar.gz rails-460d2c7c28928ab0d880675c3a7a74e81605e835.tar.bz2 rails-460d2c7c28928ab0d880675c3a7a74e81605e835.zip |
Merge pull request #5622 from rafaelfranca/fix-2492-3-2
[3-2-stable] 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 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index f9940ead58..7eeede7087 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -943,6 +943,41 @@ 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 + "<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]' size='30' 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", :method => "put") 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]' size='30' 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) |