aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/form_helper_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-22 17:17:22 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-22 17:17:22 +0000
commita7764d8fd491fb49f50397aa79d305bdb93552c5 (patch)
treea8c47eddbdcd16175a6d3141849cb8ca94b7f0e2 /actionpack/test/template/form_helper_test.rb
parenta5af3f75af86ff0abd9964bfd69483d116c12b13 (diff)
downloadrails-a7764d8fd491fb49f50397aa79d305bdb93552c5.tar.gz
rails-a7764d8fd491fb49f50397aa79d305bdb93552c5.tar.bz2
rails-a7764d8fd491fb49f50397aa79d305bdb93552c5.zip
Added FormHelper#label (closes #8641) [jcoglan]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7541 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r--actionpack/test/template/form_helper_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index a852f2af17..af63a056f8 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -70,6 +70,19 @@ class FormHelperTest < Test::Unit::TestCase
@controller = @controller.new
end
+ def test_label
+ assert_dom_equal('<label for="post_title">Title</label>', label("post", "title"))
+ assert_dom_equal('<label for="post_title">The title goes here</label>', label("post", "title", "The title goes here"))
+ assert_dom_equal(
+ '<label class="title_label" for="post_title">Title</label>',
+ label("post", "title", nil, :class => 'title_label')
+ )
+ end
+
+ def test_label_with_symbols
+ assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title))
+ end
+
def test_text_field
assert_dom_equal(
'<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title")
@@ -275,6 +288,7 @@ class FormHelperTest < Test::Unit::TestCase
_erbout = ''
form_for(:post, @post, :html => { :id => 'create-post' }) do |f|
+ _erbout.concat f.label(:title)
_erbout.concat f.text_field(:title)
_erbout.concat f.text_area(:body)
_erbout.concat f.check_box(:secret)
@@ -283,6 +297,7 @@ class FormHelperTest < Test::Unit::TestCase
expected =
"<form action='http://www.example.com' id='create-post' method='post'>" +
+ "<label for='post_title'>Title</label>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +