diff options
author | Jay Pignata <john.pignata@gmail.com> | 2009-09-04 12:43:17 -0400 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-09-28 14:36:38 +1300 |
commit | 8ef1cd9733cd12fc4e5ea25c149956a33fdffa70 (patch) | |
tree | 04db714f673f728f98799792d0d314a4eb4334c7 /actionpack/test/template | |
parent | a6757a02e12aa584bd74dbcde18a7886be8e9029 (diff) | |
download | rails-8ef1cd9733cd12fc4e5ea25c149956a33fdffa70.tar.gz rails-8ef1cd9733cd12fc4e5ea25c149956a33fdffa70.tar.bz2 rails-8ef1cd9733cd12fc4e5ea25c149956a33fdffa70.zip |
Enhancing distance_of_time_in_words to prefix year output with over and about depending upon how many months have elapsed
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#3106 state:committed]
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/date_helper_test.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index 2e4763f446..51a340d907 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -69,13 +69,14 @@ class DateHelperTest < ActionView::TestCase assert_equal "2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 30.seconds) assert_equal "12 months", distance_of_time_in_words(from, to + 1.years - 31.seconds) - # 525600..1051199 + # > 525599 assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years - 30.seconds) - assert_equal "about 1 year", distance_of_time_in_words(from, to + 2.years - 31.seconds) - - # > 1051199 - assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 30.seconds) - assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years) + assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years + 6.months - 1.day) + assert_equal "over 1 year", distance_of_time_in_words(from, to + 1.years + 6.months) + assert_equal "about 2 years", distance_of_time_in_words(from, to + 2.years + 30.seconds) + assert_equal "about 5 years", distance_of_time_in_words(from, to + 5.years + 5.months) + assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 6.months) + assert_equal "about 10 years", distance_of_time_in_words(from, to + 10.years) # test to < from assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to) @@ -104,7 +105,7 @@ class DateHelperTest < ActionView::TestCase def test_distance_in_words_with_dates start_date = Date.new 1975, 1, 31 end_date = Date.new 1977, 1, 31 - assert_equal("over 2 years", distance_of_time_in_words(start_date, end_date)) + assert_equal("about 2 years", distance_of_time_in_words(start_date, end_date)) end def test_distance_in_words_with_integers |