aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorTom Stuart <tom@experthuman.com>2011-02-12 12:07:47 +0000
committerSantiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com>2011-02-12 13:52:00 -0200
commit829de9d98e59f9b083ed96a9031cd9841c83ae47 (patch)
tree5590a875eb2bc315b9d7b8f68b658835c65b6523 /actionpack/test/template
parent03749d6c88ae8312dc959b7683851dbf8c969326 (diff)
downloadrails-829de9d98e59f9b083ed96a9031cd9841c83ae47.tar.gz
rails-829de9d98e59f9b083ed96a9031cd9841c83ae47.tar.bz2
rails-829de9d98e59f9b083ed96a9031cd9841c83ae47.zip
Add block support to button_tag helper
As per the HTML 4.01 spec: Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content. For example, a BUTTON element that contains an image functions like and may resemble an INPUT element whose type is set to "image", but the BUTTON element type allows content. Since rich content is the main purpose of the <button> element, it makes sense for the button_tag helper to accept a block. http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON http://dev.w3.org/html5/spec/the-button-element.html#the-button-element Signed-off-by: Santiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index c22af258c3..f8671f2980 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -427,6 +427,15 @@ class FormTagHelperTest < ActionView::TestCase
)
end
+ def test_button_tag_with_block
+ assert_dom_equal('<button name="button" type="submit">Content</button>', button_tag { 'Content' })
+ end
+
+ def test_button_tag_with_block_and_options
+ output = button_tag(:name => 'temptation', :type => 'button') { content_tag(:strong, 'Do not press me') }
+ assert_dom_equal('<button name="temptation" type="button"><strong>Do not press me</strong></button>', output)
+ end
+
def test_image_submit_tag_with_confirmation
assert_dom_equal(
%(<input type="image" src="/images/save.gif" data-confirm="Are you sure?" />),