datetime_select should work with -/+ infinity dates

This commit is contained in:
Joe Van Dyk
2012-01-24 10:30:46 -08:00
parent dc826f9977
commit 59a408eb64
2 changed files with 13 additions and 1 deletions

View File

@@ -783,7 +783,7 @@ module ActionView
private
%w( sec min hour day month year ).each do |method|
define_method(method) do
@datetime.kind_of?(Fixnum) ? @datetime : @datetime.send(method) if @datetime
@datetime.kind_of?(Numeric) ? @datetime : @datetime.send(method) if @datetime
end
end

View File

@@ -2084,6 +2084,18 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, datetime_select("post", "updated_at", { :date_separator => " / ", :datetime_separator => " , ", :time_separator => " - ", :include_seconds => true })
end
def test_datetime_select_with_integer
@post = Post.new
@post.updated_at = 3
datetime_select("post", "updated_at")
end
def test_datetime_select_with_infinity # Float
@post = Post.new
@post.updated_at = (-1.0/0)
datetime_select("post", "updated_at")
end
def test_datetime_select_with_default_prompt
@post = Post.new
@post.updated_at = nil