From 8eaf479156a413b8c6e98649b6326c7baa010b43 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 5 Aug 2006 21:34:18 +0000 Subject: Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" (closes #5611) [pjhyett@gmail.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4674 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/template/date_helper_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 0e838c07cf..a3010fa7f8 100755 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -18,6 +18,16 @@ class DateHelperTest < Test::Unit::TestCase assert_equal "about 3 hours", distance_of_time_in_words(from, Time.mktime(2004, 3, 7, 0, 41)) assert_equal "about 4 hours", distance_of_time_in_words(from, Time.mktime(2004, 3, 7, 1, 20)) assert_equal "2 days", distance_of_time_in_words(from, Time.mktime(2004, 3, 9, 15, 40)) + + # test greater date separation + assert_equal "29 days", distance_of_time_in_words(from, Time.mktime(2004, 4, 5, 21, 41, 18)) + assert_equal "about 1 month", distance_of_time_in_words(from, Time.mktime(2004, 4, 6, 21, 41, 18)) + assert_equal "about 1 month", distance_of_time_in_words(from, Time.mktime(2004, 4, 7, 21, 41, 18)) + assert_equal "2 months", distance_of_time_in_words(from, Time.mktime(2004, 5, 6, 21, 41, 18)) + assert_equal "11 months", distance_of_time_in_words(from, Time.mktime(2005, 2, 6, 21, 41, 18)) + assert_equal "about 1 year", distance_of_time_in_words(from, Time.mktime(2005, 4, 6, 21, 41, 18)) + assert_equal "about 1 year", distance_of_time_in_words(from, Time.mktime(2005, 4, 12, 21, 41, 18)) + assert_equal "over 2 years", distance_of_time_in_words(from, Time.mktime(2006, 4, 6, 21, 41, 18)) # include seconds assert_equal "less than a minute", distance_of_time_in_words(from, Time.mktime(2004, 3, 6, 21, 41, 19), false) -- cgit v1.2.3