diff options
author | Rusty Geldmacher <rgeldmacher@sermo.com> | 2012-07-10 15:03:37 -0400 |
---|---|---|
committer | Rusty Geldmacher <rgeldmacher@sermo.com> | 2012-07-10 15:03:37 -0400 |
commit | 1a935ad7c647534f83ec03388ea1157b39eb6dcb (patch) | |
tree | ea3d49a0d02f0f1bd4cf9fbbb1a461485cf84517 /actionpack/test/template/active_model_helper_test.rb | |
parent | 836016e5070ae96006584c5b7310264b0a27f89a (diff) | |
download | rails-1a935ad7c647534f83ec03388ea1157b39eb6dcb.tar.gz rails-1a935ad7c647534f83ec03388ea1157b39eb6dcb.tar.bz2 rails-1a935ad7c647534f83ec03388ea1157b39eb6dcb.zip |
Fixed bug creating invalid HTML in select options
When a select tag is created for a field with errors, then the inserted
options will errantly have a <div class="field_with_errors"> wrapping
them.
Diffstat (limited to 'actionpack/test/template/active_model_helper_test.rb')
-rw-r--r-- | actionpack/test/template/active_model_helper_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/test/template/active_model_helper_test.rb b/actionpack/test/template/active_model_helper_test.rb index 24511df444..86bccdfade 100644 --- a/actionpack/test/template/active_model_helper_test.rb +++ b/actionpack/test/template/active_model_helper_test.rb @@ -41,6 +41,19 @@ class ActiveModelHelperTest < ActionView::TestCase ) end + def test_select_with_errors + assert_dom_equal( + %(<div class="field_with_errors"><select name="post[author_name]" id="post_author_name"><option value="a">a</option>\n<option value="b">b</option></select></div>), + select("post", "author_name", [:a, :b]) + ) + end + + def test_select_with_errors_and_blank_option + expected_dom = %(<div class="field_with_errors"><select name="post[author_name]" id="post_author_name"><option value="">Choose one...</option>\n<option value="a">a</option>\n<option value="b">b</option></select></div>) + assert_dom_equal(expected_dom, select("post", "author_name", [:a, :b], :include_blank => 'Choose one...')) + assert_dom_equal(expected_dom, select("post", "author_name", [:a, :b], :prompt => 'Choose one...')) + end + def test_date_select_with_errors assert_dom_equal( %(<div class="field_with_errors"><select id="post_updated_at_1i" name="post[updated_at(1i)]">\n<option selected="selected" value="2004">2004</option>\n<option value="2005">2005</option>\n</select>\n<input id="post_updated_at_2i" name="post[updated_at(2i)]" type="hidden" value="6" />\n<input id="post_updated_at_3i" name="post[updated_at(3i)]" type="hidden" value="1" />\n</div>), @@ -82,4 +95,5 @@ class ActiveModelHelperTest < ActionView::TestCase ensure ActionView::Base.field_error_proc = old_proc if old_proc end + end |