mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:08 -05:00
fix tests
This commit is contained in:
@@ -3,14 +3,14 @@ require 'active_support/time'
|
||||
|
||||
class DateTimeExtCalculationsTest < Test::Unit::TestCase
|
||||
def test_to_s
|
||||
datetime = DateTime.new(2005, 2, 21, 14, 30, 0, 0)
|
||||
datetime = Time.new(2005, 2, 21, 14, 30, 0).to_datetime
|
||||
assert_equal "2005-02-21 14:30:00", datetime.to_s(:db)
|
||||
assert_equal "14:30", datetime.to_s(:time)
|
||||
assert_equal "21 Feb 14:30", datetime.to_s(:short)
|
||||
assert_equal "February 21, 2005 14:30", datetime.to_s(:long)
|
||||
assert_equal "Mon, 21 Feb 2005 14:30:00 +0000", datetime.to_s(:rfc822)
|
||||
assert_equal "Mon, 21 Feb 2005 14:30:00 #{datetime.formatted_offset(false)}", datetime.to_s(:rfc822)
|
||||
assert_equal "February 21st, 2005 14:30", datetime.to_s(:long_ordinal)
|
||||
assert_match(/^2005-02-21T14:30:00(Z|\+00:00)$/, datetime.to_s)
|
||||
assert_equal "2005-02-21T14:30:00#{datetime.formatted_offset(true)}", datetime.to_s
|
||||
end
|
||||
|
||||
def test_readable_inspect
|
||||
|
||||
@@ -9,7 +9,7 @@ class RangeTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_to_s_from_times
|
||||
date_range = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30)
|
||||
date_range = Time.new(2005, 12, 10, 15, 30)..Time.new(2005, 12, 10, 17, 30)
|
||||
assert_equal "BETWEEN '2005-12-10 15:30:00' AND '2005-12-10 17:30:00'", date_range.to_s(:db)
|
||||
end
|
||||
|
||||
|
||||
@@ -495,7 +495,6 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
|
||||
time = Time.utc(2005, 2, 21, 17, 44, 30)
|
||||
assert_equal time.to_default_s, time.to_s
|
||||
assert_equal time.to_default_s, time.to_s(:doesnt_exist)
|
||||
assert_equal "2005-02-21 17:44:30", time.to_s(:db)
|
||||
assert_equal "21 Feb 17:44", time.to_s(:short)
|
||||
assert_equal "17:44", time.to_s(:time)
|
||||
assert_equal "February 21, 2005 17:44", time.to_s(:long)
|
||||
@@ -507,6 +506,10 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
|
||||
assert_equal "Thu, 05 Feb 2009 14:30:05 -0600", Time.local(2009, 2, 5, 14, 30, 5).to_s(:rfc822)
|
||||
assert_equal "Mon, 09 Jun 2008 04:05:01 -0500", Time.local(2008, 6, 9, 4, 5, 1).to_s(:rfc822)
|
||||
end
|
||||
|
||||
# this one's a special snowflake because the db time is local
|
||||
time = Time.new(2005, 2, 21, 17, 44, 30)
|
||||
assert_equal "2005-02-21 17:44:30", time.to_s(:db)
|
||||
end
|
||||
|
||||
def test_custom_date_format
|
||||
|
||||
@@ -91,7 +91,8 @@ class TimeWithZoneTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_to_s_db
|
||||
assert_equal '2000-01-01 00:00:00', @twz.to_s(:db)
|
||||
# This test assumes the local timezone of the machine is Pacific.
|
||||
assert_equal '1999-12-31 16:00:00', @twz.to_s(:db)
|
||||
end
|
||||
|
||||
def test_xmlschema
|
||||
|
||||
Reference in New Issue
Block a user