aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-02-16 23:15:59 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-02-16 23:15:59 +0000
commite7ebd656b31244c3da5abf45e100c8e976c79d50 (patch)
treed7f5d7dbc32242eb46a02f5c439e84a6727a316d /activesupport/test/core_ext/time_with_zone_test.rb
parent3025ff28cc5aad02a71bebe1d155aa86e887d781 (diff)
downloadrails-e7ebd656b31244c3da5abf45e100c8e976c79d50.tar.gz
rails-e7ebd656b31244c3da5abf45e100c8e976c79d50.tar.bz2
rails-e7ebd656b31244c3da5abf45e100c8e976c79d50.zip
TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8884 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 38646caa79..3421b85e60 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -121,17 +121,29 @@ uses_tzinfo 'TimeWithZoneTest' do
assert @twz.eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), TimeZone["Hawaii"]) )
end
- def test_plus
+ def test_plus_with_integer
assert_equal Time.utc(1999, 12, 31, 19, 0 ,5), (@twz + 5).time
end
+ def test_plus_with_integer_when_self_wraps_datetime
+ datetime = DateTime.civil(2000, 1, 1, 0)
+ twz = ActiveSupport::TimeWithZone.new(datetime, @time_zone)
+ assert_equal DateTime.civil(1999, 12, 31, 19, 0 ,5), (twz + 5).time
+ end
+
def test_plus_with_duration
assert_equal Time.utc(2000, 1, 5, 19, 0 ,0), (@twz + 5.days).time
end
- def test_minus
+ def test_minus_with_integer
assert_equal Time.utc(1999, 12, 31, 18, 59 ,55), (@twz - 5).time
end
+
+ def test_minus_with_integer_when_self_wraps_datetime
+ datetime = DateTime.civil(2000, 1, 1, 0)
+ twz = ActiveSupport::TimeWithZone.new(datetime, @time_zone)
+ assert_equal DateTime.civil(1999, 12, 31, 18, 59 ,55), (twz - 5).time
+ end
def test_minus_with_duration
assert_equal Time.utc(1999, 12, 26, 19, 0 ,0), (@twz - 5.days).time
@@ -174,6 +186,12 @@ uses_tzinfo 'TimeWithZoneTest' do
def test_acts_like_time
assert @twz.acts_like?(:time)
+ assert ActiveSupport::TimeWithZone.new(DateTime.civil(2000), @time_zone).acts_like?(:time)
+ end
+
+ def test_acts_like_date
+ assert_equal false, @twz.acts_like?(:date)
+ assert_equal false, ActiveSupport::TimeWithZone.new(DateTime.civil(2000), @time_zone).acts_like?(:date)
end
def test_is_a