mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add tests for time_field and date_field helpers
These tests check the values of 'min' and 'max' input attrs
This commit is contained in:
parent
a9a9e8a3cb
commit
30847b499b
1 changed files with 18 additions and 0 deletions
|
@ -644,6 +644,15 @@ class FormHelperTest < ActionView::TestCase
|
||||||
assert_dom_equal(expected, date_field("post", "written_on"))
|
assert_dom_equal(expected, date_field("post", "written_on"))
|
||||||
end
|
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
|
def test_date_field_with_timewithzone_value
|
||||||
previous_time_zone, Time.zone = Time.zone, 'UTC'
|
previous_time_zone, Time.zone = Time.zone, 'UTC'
|
||||||
expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
|
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"))
|
assert_dom_equal(expected, time_field("post", "written_on"))
|
||||||
end
|
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
|
def test_time_field_with_timewithzone_value
|
||||||
previous_time_zone, Time.zone = Time.zone, 'UTC'
|
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" />}
|
expected = %{<input id="post_written_on" name="post[written_on]" type="time" value="01:02:03.000" />}
|
||||||
|
|
Loading…
Reference in a new issue