aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/date_ext_test.rb8
-rw-r--r--activesupport/test/core_ext/date_time_ext_test.rb5
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb7
3 files changed, 19 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb
index c403d7fb11..1f94b80edc 100644
--- a/activesupport/test/core_ext/date_ext_test.rb
+++ b/activesupport/test/core_ext/date_ext_test.rb
@@ -20,6 +20,13 @@ class DateExtCalculationsTest < Test::Unit::TestCase
def test_to_time
assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time
assert_equal Time.local_time(2039, 2, 21), Date.new(2039, 2, 21).to_time
+ silence_warnings do
+ 0.upto(138) do |year|
+ [:utc, :local].each do |format|
+ assert_equal year, Date.new(year).to_time(format).year
+ end
+ end
+ end
end
def test_to_datetime
@@ -89,7 +96,6 @@ class DateExtCalculationsTest < Test::Unit::TestCase
assert_equal Date.new(2005,3,31), Date.new(2005,3,20).end_of_month
assert_equal Date.new(2005,2,28), Date.new(2005,2,20).end_of_month
assert_equal Date.new(2005,4,30), Date.new(2005,4,20).end_of_month
-
end
def test_beginning_of_year
diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb
index 278c05797b..f9af059acd 100644
--- a/activesupport/test/core_ext/date_time_ext_test.rb
+++ b/activesupport/test/core_ext/date_time_ext_test.rb
@@ -40,6 +40,11 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase
assert_equal DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24)), DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24)).to_time
end
+ def test_civil_from_format
+ assert_equal DateTime.civil(2010, 5, 4, 0, 0, 0, DateTime.local_offset), DateTime.civil_from_format(:local, 2010, 5, 4)
+ assert_equal DateTime.civil(2010, 5, 4, 0, 0, 0, 0), DateTime.civil_from_format(:utc, 2010, 5, 4)
+ end
+
def test_seconds_since_midnight
assert_equal 1,DateTime.civil(2005,1,1,0,0,1).seconds_since_midnight
assert_equal 60,DateTime.civil(2005,1,1,0,1,0).seconds_since_midnight
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index c24c8619c6..342d6ab577 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -587,6 +587,13 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
DateTime.civil(2039, 2, 21, 17, 44, 30, 0, 0)
assert_equal ::Date::ITALY, Time.time_with_datetime_fallback(:utc, 2039, 2, 21, 17, 44, 30, 1).start # use Ruby's default start value
end
+ silence_warnings do
+ 0.upto(138) do |year|
+ [:utc, :local].each do |format|
+ assert_equal year, Time.time_with_datetime_fallback(format, year).year
+ end
+ end
+ end
end
def test_utc_time