aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/form_helper_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-03-27 19:45:51 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-03-27 19:45:51 -0300
commit32763a82444ba5eb711ec0e5d6380818e5f2695d (patch)
treecdb2cbd81f67e7c1bd4bd09c9182f4c108faad3f /actionpack/test/template/form_helper_test.rb
parent6ce0a6de7e698dabcef10b8ebc855b47555d540b (diff)
downloadrails-32763a82444ba5eb711ec0e5d6380818e5f2695d.tar.gz
rails-32763a82444ba5eb711ec0e5d6380818e5f2695d.tar.bz2
rails-32763a82444ba5eb711ec0e5d6380818e5f2695d.zip
Check if the options hash already exists and merge it with the another
hash. Closes #2492 and #5615
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r--actionpack/test/template/form_helper_test.rb24
1 files changed, 18 insertions, 6 deletions
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
+ "<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
- 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')
@@ -1058,14 +1072,12 @@ class FormHelperTest < ActionView::TestCase
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>" +
+ "<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
- ensure
- ActionView::Base.field_error_proc = default_field_error_proc
end
def test_form_for_with_namespace