aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
authorMatt Bridges <mbridges.91@gmail.com>2012-01-03 19:53:13 -0600
committerMatt Bridges <mbridges.91@gmail.com>2012-02-21 16:27:08 -0600
commitd6366625e04c516bf5f4bd6f561c3bb1945b0c82 (patch)
tree34c9ada6ee0e422235ec3cfeed7439806ebdfa50 /activesupport/test/core_ext/time_ext_test.rb
parent7cfd1bd76a41bea528c945d821a9fbc3902af479 (diff)
downloadrails-d6366625e04c516bf5f4bd6f561c3bb1945b0c82.tar.gz
rails-d6366625e04c516bf5f4bd6f561c3bb1945b0c82.tar.bz2
rails-d6366625e04c516bf5f4bd6f561c3bb1945b0c82.zip
Adding :last_week, :last_month, and :last_year aliases to Time and Date
core extensions
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index cfd5a27f08..076373cbf0 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -198,6 +198,10 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).prev_year
end
+ def test_last_year
+ assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).last_year
+ end
+
def test_next_year
assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).next_year
end
@@ -505,6 +509,16 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2006,11,15), Time.local(2006,11,23,0,0,0).prev_week(:wednesday)
end
end
+
+ def test_last_week
+ with_env_tz 'US/Eastern' do
+ assert_equal Time.local(2005,2,21), Time.local(2005,3,1,15,15,10).last_week
+ assert_equal Time.local(2005,2,22), Time.local(2005,3,1,15,15,10).last_week(:tuesday)
+ assert_equal Time.local(2005,2,25), Time.local(2005,3,1,15,15,10).last_week(:friday)
+ assert_equal Time.local(2006,10,30), Time.local(2006,11,6,0,0,0).last_week
+ assert_equal Time.local(2006,11,15), Time.local(2006,11,23,0,0,0).last_week(:wednesday)
+ end
+ end
def test_next_week
with_env_tz 'US/Eastern' do
@@ -662,6 +676,10 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2004, 2, 29), Time.local(2004, 3, 31).prev_month
end
+ def test_last_month_on_31st
+ assert_equal Time.local(2004, 2, 29), Time.local(2004, 3, 31).last_month
+ end
+
def test_xmlschema_is_available
assert_nothing_raised { Time.now.xmlschema }
end