diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 30 | ||||
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 30 |
2 files changed, 60 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 88014a6564..d62406c2d3 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -349,6 +349,36 @@ class FormHelperTest < ActionView::TestCase ) end + def search_field + expected = %{<input id="contact_notes_query" size="30" name="contact[notes_query]" type="search" />} + assert_dom_equal(expected, search_field("contact", "notes_query")) + end + + def test_telephone_field + expected = %{<input id="user_cell" size="30" name="user[cell]" type="tel" />} + assert_dom_equal(expected, telephone_field("user", "cell")) + end + + def test_url_field + expected = %{<input id="user_homepage" size="30" name="user[homepage]" type="url" />} + assert_dom_equal(expected, url_field("user", "homepage")) + end + + def test_email_field + expected = %{<input id="user_address" size="30" name="user[address]" type="email" />} + assert_dom_equal(expected, email_field("user", "address")) + end + + def test_number_field + expected = %{<input name="order[quantity]" size="30" max="9" id="order_quantity" type="number" min="1" />} + assert_dom_equal(expected, number_field("order", "quantity", :in => 1...10)) + end + + def test_range_input + expected = %{<input name="hifi[volume]" step="0.1" size="30" max="11" id="hifi_volume" type="range" min="0" />} + assert_dom_equal(expected, range_field("hifi", "volume", :in => 0..11, :step => 0.1)) + end + def test_explicit_name assert_dom_equal( '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />', text_field("post", "title", "name" => "dont guess") diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 3b8760351e..ef612b879b 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -335,6 +335,36 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_search_field_tag + expected = %{<input id="query" name="query" type="search" />} + assert_dom_equal(expected, search_field_tag("query")) + end + + def telephone_field_tag + expected = %{<input id="cell" name="cell" type="tel" />} + assert_dom_equal(expected, telephone_field_tag("cell")) + end + + def test_url_field_tag + expected = %{<input id="homepage" name="homepage" type="url" />} + assert_dom_equal(expected, url_field_tag("homepage")) + end + + def test_email_field_tag + expected = %{<input id="address" name="address" type="email" />} + assert_dom_equal(expected, email_field_tag("address")) + end + + def test_number_field_tag + expected = %{<input name="quantity" max="9" id="quantity" type="number" min="1" />} + assert_dom_equal(expected, number_field_tag("quantity", nil, :in => 1...10)) + end + + def test_range_input_tag + expected = %{<input name="volume" step="0.1" max="11" id="volume" type="range" min="0" />} + assert_dom_equal(expected, range_field_tag("volume", nil, :in => 0..11, :step => 0.1)) + end + def test_pass assert_equal 1, 1 end |