diff options
author | Carlos Galdino <carloshsgaldino@gmail.com> | 2012-05-22 21:04:12 -0300 |
---|---|---|
committer | Carlos Galdino <carloshsgaldino@gmail.com> | 2012-05-22 23:33:07 -0300 |
commit | 30847b499b3c824864c9652f6d12ceb8219b363d (patch) | |
tree | e55405f5a72d523a9fdf43a6c8dbd27701ce3c20 | |
parent | a9a9e8a3cb64faddc347271c00f975e04a92e394 (diff) | |
download | rails-30847b499b3c824864c9652f6d12ceb8219b363d.tar.gz rails-30847b499b3c824864c9652f6d12ceb8219b363d.tar.bz2 rails-30847b499b3c824864c9652f6d12ceb8219b363d.zip |
Add tests for time_field and date_field helpers
These tests check the values of 'min' and 'max' input attrs
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 97c8025db3..c9b39ed18f 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -644,6 +644,15 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal(expected, date_field("post", "written_on")) end + def test_date_field_with_extra_attrs + expected = %{<input id="post_written_on" step="2" max="2010-08-15" min="2000-06-15" name="post[written_on]" type="date" value="2004-06-15" />} + @post.written_on = DateTime.new(2004, 6, 15) + min_value = DateTime.new(2000, 6, 15) + max_value = DateTime.new(2010, 8, 15) + step = 2 + assert_dom_equal(expected, date_field("post", "written_on", :min => min_value, :max => max_value, :step => step)) + end + def test_date_field_with_timewithzone_value previous_time_zone, Time.zone = Time.zone, 'UTC' expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />} @@ -670,6 +679,15 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal(expected, time_field("post", "written_on")) end + def test_time_field_with_extra_attrs + expected = %{<input id="post_written_on" step="60" max="10:25:00.000" min="20:45:30.000" name="post[written_on]" type="time" value="01:02:03.000" />} + @post.written_on = DateTime.new(2004, 6, 15, 1, 2, 3) + min_value = DateTime.new(2000, 6, 15, 20, 45, 30) + max_value = DateTime.new(2010, 8, 15, 10, 25, 00) + step = 60 + assert_dom_equal(expected, time_field("post", "written_on", :min => min_value, :max => max_value, :step => step)) + 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" />} |