diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-05-17 23:13:39 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-05-17 23:13:39 -0700 |
commit | d8e8ab1c5351a3b8707143a787fed514b75a4144 (patch) | |
tree | 413b070e34022ddf4a8889b0045dd4582a8a65bc /actionpack/test/template/form_helper_test.rb | |
parent | b23ac936a6ef980547666da002681a77d8340573 (diff) | |
parent | 446940c366d588e7e895a64caf325f5f99cba0fb (diff) | |
download | rails-d8e8ab1c5351a3b8707143a787fed514b75a4144.tar.gz rails-d8e8ab1c5351a3b8707143a787fed514b75a4144.tar.bz2 rails-d8e8ab1c5351a3b8707143a787fed514b75a4144.zip |
Merge pull request #5715 from soulim/add_time_input_control
Add HTML5 input[type="time"] helper
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index beb3ea752a..27cc3ad48a 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -646,6 +646,32 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal(expected, date_field("post", "written_on")) end + def test_time_field + expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="00:00:00.000" />} + assert_dom_equal(expected, time_field("post", "written_on")) + end + + def test_time_field_with_datetime_value + expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="01:02:03.000" />} + @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3) + assert_dom_equal(expected, time_field("post", "written_on")) + end + + def test_time_field_with_timewithzone_value + previous_time_zone, Time.zone = Time.zone, 'UTC' + expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="01:02:03.000" />} + @post.written_on = Time.zone.parse('2004-06-15 01:02:03') + assert_dom_equal(expected, time_field("post", "written_on")) + ensure + Time.zone = previous_time_zone + end + + def test_time_field_with_nil_value + expected = %{<input id="post_written_on" name="post[written_on]" type="time" />} + @post.written_on = nil + assert_dom_equal(expected, time_field("post", "written_on")) + end + def test_url_field expected = %{<input id="user_homepage" name="user[homepage]" type="url" />} assert_dom_equal(expected, url_field("user", "homepage")) |