aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb4
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb10
2 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 2377d3c63c..fef8a521da 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -454,6 +454,10 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal 0, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 0), TimeZone['UTC'] )
assert_equal(-1, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 1), TimeZone['UTC'] ))
end
+
+ def test_minus_with_time_with_zone
+ assert_equal 86_400.0, Time.utc(2000, 1, 2) - ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), TimeZone['UTC'] )
+ end
protected
def with_timezone(new_tz = 'US/Eastern')
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 1a2f3e6e47..9276656db5 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -121,6 +121,16 @@ uses_tzinfo 'TimeWithZoneTest' do
def test_minus_with_duration
assert_equal Time.utc(1999, 12, 26, 19, 0 ,0), (@twz - 5.days).time
end
+
+ def test_minus_with_time
+ assert_equal 86_400.0, ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2), TimeZone['UTC'] ) - Time.utc(2000, 1, 1)
+ end
+
+ def test_minus_with_time_with_zone
+ twz1 = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), TimeZone['UTC'] )
+ twz2 = ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2), TimeZone['UTC'] )
+ assert_equal 86_400.0, twz2 - twz1
+ end
def test_to_time
assert_equal @twz, @twz.to_time