From 6e69b42b21d8e76c4d87b6fbc4222f55d3b11a06 Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Tue, 20 Apr 2010 23:16:18 -0500 Subject: Let label helpers accept blocks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/test/template/form_helper_test.rb | 10 +++++++--- actionpack/test/template/form_tag_helper_test.rb | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'actionpack/test') 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("post", "title", "The title goes here", :value => "great title")) end + def test_label_with_block + assert_dom_equal('', label(:post, :title) { "The title, please:" }) + end + def test_text_field assert_dom_equal( '', 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 = "
" + - "" + + "" + "" + "" + "" + @@ -485,7 +489,7 @@ class FormHelperTest < ActionView::TestCase "" + "" + "" + - "" + + "" + "
" 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_tag { "Blocked" }) + end + + def test_label_tag_with_block_and_argument + output = label_tag("clock") { "Grandfather" } + assert_dom_equal('', output) + end + def test_boolean_options assert_dom_equal %(), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") assert_dom_equal %(), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) -- cgit v1.2.3