aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 170caf3e09..a7faf4808b 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -348,7 +348,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal midnight.midnight, (midnight + 1.hour + 0.000001).midnight
end
- def test_days_in_month
+ def test_days_in_month_with_year
assert_equal 31, Time.days_in_month(1, 2005)
assert_equal 28, Time.days_in_month(2, 2005)
@@ -367,6 +367,18 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal 30, Time.days_in_month(11, 2005)
assert_equal 31, Time.days_in_month(12, 2005)
end
+
+ uses_mocha 'TestTimeDaysInMonthWithoutYearArg' do
+ def test_days_in_month_feb_in_common_year_without_year_arg
+ Time.stubs(:now).returns(Time.utc(2007))
+ assert_equal 28, Time.days_in_month(2)
+ end
+
+ def test_days_in_month_feb_in_leap_year_without_year_arg
+ Time.stubs(:now).returns(Time.utc(2008))
+ assert_equal 29, Time.days_in_month(2)
+ end
+ end
def test_time_with_datetime_fallback
assert_equal Time.time_with_datetime_fallback(:utc, 2005, 2, 21, 17, 44, 30), Time.utc(2005, 2, 21, 17, 44, 30)