diff options
author | Stephen Celis <stephen@stephencelis.com> | 2010-04-20 23:16:18 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-15 08:59:08 +0200 |
commit | 6e69b42b21d8e76c4d87b6fbc4222f55d3b11a06 (patch) | |
tree | f3c036e8d4cfe261984bdba8d14cae2612dc9fd0 /actionpack/test | |
parent | 35a114a8941cb22d29a536f1215a23a8cf7c4756 (diff) | |
download | rails-6e69b42b21d8e76c4d87b6fbc4222f55d3b11a06.tar.gz rails-6e69b42b21d8e76c4d87b6fbc4222f55d3b11a06.tar.bz2 rails-6e69b42b21d8e76c4d87b6fbc4222f55d3b11a06.zip |
Let label helpers accept blocks.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 10 | ||||
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 9 |
2 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 2234fbece9..da2adc9869 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -139,6 +139,10 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal('<label for="post_title_great_title">The title goes here</label>', label("post", "title", "The title goes here", :value => "great title")) end + def test_label_with_block + assert_dom_equal('<label for="post_title">The title, please:</label>', label(:post, :title) { "The title, please:" }) + 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") @@ -448,7 +452,7 @@ class FormHelperTest < ActionView::TestCase def test_form_for assert_deprecated do form_for(:post, @post, :html => { :id => 'create-post' }) do |f| - concat f.label(:title) + concat f.label(:title) { "The Title" } concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) @@ -458,7 +462,7 @@ class FormHelperTest < ActionView::TestCase expected = "<form action='http://www.example.com' id='create-post' method='post'>" + - "<label for='post_title'>Title</label>" + + "<label for='post_title'>The 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]' type='hidden' value='0' />" + @@ -485,7 +489,7 @@ class FormHelperTest < ActionView::TestCase "<input name='other_name[title]' size='30' id='other_name_title' value='Hello World' type='text' />" + "<textarea name='other_name[body]' id='other_name_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<input name='other_name[secret]' value='0' type='hidden' />" + - "<input name='other_name[secret]' checked='checked' id='other_name_secret' value='1' type='checkbox' />" + + "<input name='other_name[secret]' checked='checked' id='other_name_secret' value='1' type='checkbox' />" + "<input name='commit' id='other_name_submit' value='Create post' type='submit' /></form>" assert_dom_equal expected, output_buffer diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index abb0e1df93..1e116c041f 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -288,6 +288,15 @@ class FormTagHelperTest < ActionView::TestCase assert_match VALID_HTML_ID, label_elem['for'] end + def test_label_tag_with_block + assert_dom_equal('<label>Blocked</label>', label_tag { "Blocked" }) + end + + def test_label_tag_with_block_and_argument + output = label_tag("clock") { "Grandfather" } + assert_dom_equal('<label for="clock">Grandfather</label>', output) + end + def test_boolean_options assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") assert_dom_equal %(<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) |