diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-04 22:00:53 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-04 22:00:53 +0000 |
commit | 1b32a305df40829c650a5254441eaec491e9f086 (patch) | |
tree | 8656077640d3c3c1117259a6936d81b3440d1279 /activesupport/test | |
parent | 4685fa0c20fbf3e78eaad94756e0f4a644447a10 (diff) | |
download | rails-1b32a305df40829c650a5254441eaec491e9f086.tar.gz rails-1b32a305df40829c650a5254441eaec491e9f086.tar.bz2 rails-1b32a305df40829c650a5254441eaec491e9f086.zip |
Add Date#since, ago, beginning_of_day, and end_of_day. Date + seconds works now. Closes #8575.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6937 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/date_ext_test.rb | 16 | ||||
-rw-r--r-- | activesupport/test/core_ext/numeric_ext_test.rb | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 26905add17..b81e18e13b 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -139,4 +139,20 @@ class DateExtCalculationsTest < Test::Unit::TestCase def test_tomorrow_constructor assert_equal Date.today + 1, Date.tomorrow end + + def test_since + assert_equal Time.local(2005,2,21,0,0,45), Date.new(2005,2,21).since(45) + end + + def test_ago + assert_equal Time.local(2005,2,20,23,59,15), Date.new(2005,2,21).ago(45) + end + + def test_beginning_of_day + assert_equal Time.local(2005,2,21,0,0,0), Date.new(2005,2,21).beginning_of_day + end + + def test_end_of_day + assert_equal Time.local(2005,2,21,23,59,59), Date.new(2005,2,21).end_of_day + end end diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index 975b5d1283..e69704878b 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -90,7 +90,9 @@ class NumericExtDateTest < Test::Unit::TestCase def test_date_plus_duration assert_equal @today + 1, @today + 1.day assert_equal @today >> 1, @today + 1.month - assert_raises(ArgumentError) { @today + 1.second } + assert_equal @today.to_time.since(1), @today + 1.second + assert_equal @today.to_time.since(60), @today + 1.minute + assert_equal @today.to_time.since(60*60), @today + 1.hour end def test_chaining_duration_operations |