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.rb2
-rw-r--r--activesupport/test/core_ext/date_time_ext_test.rb2
2 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb
index b86bb2dc6b..beeaa6ce4d 100644
--- a/activesupport/test/core_ext/date_ext_test.rb
+++ b/activesupport/test/core_ext/date_ext_test.rb
@@ -94,12 +94,14 @@ class DateExtCalculationsTest < Test::Unit::TestCase
def test_years_ago
assert_equal Date.new(2004,6,5), Date.new(2005,6,5).years_ago(1)
assert_equal Date.new(1998,6,5), Date.new(2005,6,5).years_ago(7)
+ assert_equal Date.new(2003,2,28), Date.new(2004,2,29).years_ago(1) # 1 year ago from leap day
end
def test_years_since
assert_equal Date.new(2006,6,5), Date.new(2005,6,5).years_since(1)
assert_equal Date.new(2012,6,5), Date.new(2005,6,5).years_since(7)
assert_equal Date.new(2182,6,5), Date.new(2005,6,5).years_since(177)
+ assert_equal Date.new(2005,2,28), Date.new(2004,2,29).years_since(1) # 1 year since leap day
end
def test_last_year
diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb
index 27c2291442..6fb4ad5881 100644
--- a/activesupport/test/core_ext/date_time_ext_test.rb
+++ b/activesupport/test/core_ext/date_time_ext_test.rb
@@ -112,12 +112,14 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase
def test_years_ago
assert_equal DateTime.civil(2004,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_ago(1)
assert_equal DateTime.civil(1998,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_ago(7)
+ assert_equal DateTime.civil(2003,2,28,10), DateTime.civil(2004,2,29,10,0,0).years_ago(1) # 1 year ago from leap day
end
def test_years_since
assert_equal DateTime.civil(2006,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_since(1)
assert_equal DateTime.civil(2012,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_since(7)
assert_equal DateTime.civil(2182,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_since(177)
+ assert_equal DateTime.civil(2005,2,28,10), DateTime.civil(2004,2,29,10,0,0).years_since(1) # 1 year since leap day
end
def test_last_year