aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/date_ext_test.rb
diff options
context:
space:
mode:
authorgbuesing <gbuesing@gmail.com>2008-09-14 22:56:32 -0500
committergbuesing <gbuesing@gmail.com>2008-09-14 22:56:32 -0500
commitcce7ae54663243a224e9871f1aac2388842b0c3a (patch)
treeec225d350eb6c3502cbd41b48b36dba25b4d8dd8 /activesupport/test/core_ext/date_ext_test.rb
parentbfa12d7a02ce0e84fcd2b83f2ce6fee1386757e3 (diff)
downloadrails-cce7ae54663243a224e9871f1aac2388842b0c3a.tar.gz
rails-cce7ae54663243a224e9871f1aac2388842b0c3a.tar.bz2
rails-cce7ae54663243a224e9871f1aac2388842b0c3a.zip
Add thorough tests for Time-object #past?, #future? and #today. Fix TimeWithZone #today? to use #time instead of #utc for date comparison. Update changelog. [#720 state:resolved]
Diffstat (limited to 'activesupport/test/core_ext/date_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/date_ext_test.rb30
1 files changed, 19 insertions, 11 deletions
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb
index 49737ef2c0..b53c754780 100644
--- a/activesupport/test/core_ext/date_ext_test.rb
+++ b/activesupport/test/core_ext/date_ext_test.rb
@@ -211,17 +211,25 @@ class DateExtCalculationsTest < Test::Unit::TestCase
end
uses_mocha 'past?, today? and future?' do
- def test_today_past_future
- Date.stubs(:current).returns(Date.civil(2000, 1, 1))
- t2 = Date.civil(2000, 1, 1)
- t1, t3 = t2.yesterday, t2.tomorrow
- t4, t5 = t2 - 1.second, t2 + 1.second
-
- assert t1.past?
- assert t2.today?
- assert t3.future?
- assert t4.past?
- assert t5.today?
+ def test_today
+ Date.stubs(:current).returns(Date.new(2000, 1, 1))
+ assert_equal false, Date.new(1999, 12, 31).today?
+ assert_equal true, Date.new(2000,1,1).today?
+ assert_equal false, Date.new(2000,1,2).today?
+ end
+
+ def test_past
+ Date.stubs(:current).returns(Date.new(2000, 1, 1))
+ assert_equal true, Date.new(1999, 12, 31).past?
+ assert_equal false, Date.new(2000,1,1).past?
+ assert_equal false, Date.new(2000,1,2).past?
+ end
+
+ def test_future
+ Date.stubs(:current).returns(Date.new(2000, 1, 1))
+ assert_equal false, Date.new(1999, 12, 31).future?
+ assert_equal false, Date.new(2000,1,1).future?
+ assert_equal true, Date.new(2000,1,2).future?
end
end