diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 11:50:41 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 11:50:41 +0000 |
commit | dfac1cea3d851000116a23ab14c2b1ae981f7a12 (patch) | |
tree | 91abe3727d19f4c13affe1a2e4bc4637b35d5fdf /actionpack/test/template/form_helper_test.rb | |
parent | db41d2dd5c738ca44a07330cf02e9d817fedc34c (diff) | |
download | rails-dfac1cea3d851000116a23ab14c2b1ae981f7a12.tar.gz rails-dfac1cea3d851000116a23ab14c2b1ae981f7a12.tar.bz2 rails-dfac1cea3d851000116a23ab14c2b1ae981f7a12.zip |
Fixed that form helpers would treat string and symbol keys differently in html_options (and possibly create duplicate entries) #112 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@833 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 6b1deb575e..7f7f473564 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -15,7 +15,7 @@ class FormHelperTest < Test::Unit::TestCase $VERBOSE = old_verbose def setup - @post = Post.new + @post = Post.new def @post.errors() Class.new{ def on(field) field == "author_name" end }.new end def @post.id; 123; end @@ -47,31 +47,29 @@ class FormHelperTest < Test::Unit::TestCase end def test_text_field_with_options - assert_equal( - '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />', - text_field("post", "title", "size" => "35") - ) + expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />' + assert_equal expected, text_field("post", "title", "size" => 35) + assert_equal expected, text_field("post", "title", :size => 35) end - + def test_text_field_assuming_size - assert_equal( - '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />', - text_field("post", "title", "maxlength" => 35) - ) + expected = '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />' + assert_equal expected, text_field("post", "title", "maxlength" => 35) + assert_equal expected, text_field("post", "title", :maxlength => 35) end - + def test_check_box assert_equal( '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />', check_box("post", "secret") ) - + @post.secret = 0 assert_equal( '<input id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />', - check_box("post", "secret") + check_box("post", "secret") ) - + @post.secret = true assert_equal( '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />', @@ -81,20 +79,20 @@ class FormHelperTest < Test::Unit::TestCase def test_radio_button assert_equal('<input checked="checked" id="post_title" name="post[title]" size="30" type="radio" value="Hello World" />', - radio_button("post", "title", "Hello World") + radio_button("post", "title", "Hello World") ) assert_equal('<input id="post_title" name="post[title]" size="30" type="radio" value="Goodbye World" />', - radio_button("post", "title", "Goodbye World") + radio_button("post", "title", "Goodbye World") ) end - + def test_text_area assert_equal( '<textarea cols="40" id="post_body" name="post[body]" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>', text_area("post", "body") ) end - + def test_text_area_with_escapes @post.body = "Back to <i>the</i> hill and over it again!" assert_equal( @@ -109,12 +107,11 @@ class FormHelperTest < Test::Unit::TestCase text_area("post", "body") ) end - - + def test_explicit_name assert_equal( '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />', text_field("post", "title", "name" => "dont guess") - ) + ) assert_equal( '<textarea cols="40" id="post_body" name="really!" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>', text_area("post", "body", "name" => "really!") @@ -123,12 +120,18 @@ class FormHelperTest < Test::Unit::TestCase '<input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" /><input name="i mean it" type="hidden" value="0" />', check_box("post", "secret", "name" => "i mean it") ) + assert_equal text_field("post", "title", "name" => "dont guess"), + text_field("post", "title", :name => "dont guess") + assert_equal text_area("post", "body", "name" => "really!"), + text_area("post", "body", :name => "really!") + assert_equal check_box("post", "secret", "name" => "i mean it"), + check_box("post", "secret", :name => "i mean it") end - + def test_explicit_id assert_equal( '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title", "id" => "dont guess") - ) + ) assert_equal( '<textarea cols="40" id="really!" name="post[body]" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>', text_area("post", "body", "id" => "really!") @@ -137,6 +140,12 @@ class FormHelperTest < Test::Unit::TestCase '<input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />', check_box("post", "secret", "id" => "i mean it") ) + assert_equal text_field("post", "title", "id" => "dont guess"), + text_field("post", "title", :id => "dont guess") + assert_equal text_area("post", "body", "id" => "really!"), + text_area("post", "body", :id => "really!") + assert_equal check_box("post", "secret", "id" => "i mean it"), + check_box("post", "secret", :id => "i mean it") end def test_auto_index @@ -159,7 +168,5 @@ class FormHelperTest < Test::Unit::TestCase assert_equal("<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"radio\" value=\"Goodbye World\" />", radio_button("post[]", "title", "Goodbye World") ) - end - end |