diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2015-11-10 17:13:01 +0000 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2015-11-10 17:13:01 +0000 |
commit | 6c3db3652faaa54e4e0b052e4042717c73f0d2f8 (patch) | |
tree | 02e92e3ea020bf4b13dfb3f7be2d66ac6dcf5583 /activesupport/test/core_ext | |
parent | 320b79f54c9ae543eeb62581611b2d36d5f66d41 (diff) | |
parent | 55b463f599dafc719da4a395f77482049b00f2d7 (diff) | |
download | rails-6c3db3652faaa54e4e0b052e4042717c73f0d2f8.tar.gz rails-6c3db3652faaa54e4e0b052e4042717c73f0d2f8.tar.bz2 rails-6c3db3652faaa54e4e0b052e4042717c73f0d2f8.zip |
Merge pull request #22244 from pacso/time-days-in-year
Add days_in_year method to Time class
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 2d0fb70a6b..e45df63fd5 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -617,6 +617,25 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase end end + def test_days_in_year_with_year + assert_equal 365, Time.days_in_year(2005) + assert_equal 366, Time.days_in_year(2004) + assert_equal 366, Time.days_in_year(2000) + assert_equal 365, Time.days_in_year(1900) + end + + def test_days_in_year_in_common_year_without_year_arg + Time.stub(:now, Time.utc(2007)) do + assert_equal 365, Time.days_in_year + end + end + + def test_days_in_year_in_leap_year_without_year_arg + Time.stub(:now, Time.utc(2008)) do + assert_equal 366, Time.days_in_year + end + end + def test_last_month_on_31st assert_equal Time.local(2004, 2, 29), Time.local(2004, 3, 31).last_month end |