diff options
author | Yehuda Katz <wycats@gmail.com> | 2011-11-22 13:01:37 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2011-11-22 13:01:37 -0800 |
commit | a93ee92da2b9ba83e3a3fe0b8d4dd5cac2790f15 (patch) | |
tree | 46a33467eca7a163117ed439c65b02e96248060e /activesupport/test/core_ext | |
parent | 9b7be78820c5510b2f841dc2197ed3a32ad8dd19 (diff) | |
parent | a4912078c7d345a347f023ef28c0986458bdebf5 (diff) | |
download | rails-a93ee92da2b9ba83e3a3fe0b8d4dd5cac2790f15.tar.gz rails-a93ee92da2b9ba83e3a3fe0b8d4dd5cac2790f15.tar.bz2 rails-a93ee92da2b9ba83e3a3fe0b8d4dd5cac2790f15.zip |
Merge pull request #3725 from marcandre/twz_eql
Fix inconsistencies with Time{WithZone}#{hash,eql?}
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 6 | ||||
-rw-r--r-- | activesupport/test/core_ext/time_with_zone_test.rb | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index a1e088a28d..d2ff44e1b4 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -744,6 +744,12 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal(-1, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 0, 0, 1), ActiveSupport::TimeZone['UTC'] )) end + def test_eql? + assert_equal true, Time.utc(2000).eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone['UTC']) ) + assert_equal true, Time.utc(2000).eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone["Hawaii"]) ) + assert_equal false,Time.utc(2000, 1, 1, 0, 0, 1).eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::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), ActiveSupport::TimeZone['UTC'] ) end diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index b2309ae806..9d9e411c28 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -200,8 +200,15 @@ class TimeWithZoneTest < Test::Unit::TestCase end def test_eql? - assert @twz.eql?(Time.utc(2000)) - assert @twz.eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone["Hawaii"]) ) + assert_equal true, @twz.eql?(Time.utc(2000)) + assert_equal true, @twz.eql?( ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone["Hawaii"]) ) + assert_equal false, @twz.eql?( Time.utc(2000, 1, 1, 0, 0, 1) ) + assert_equal false, @twz.eql?( DateTime.civil(1999, 12, 31, 23, 59, 59) ) + end + + def test_hash + assert_equal Time.utc(2000).hash, @twz.hash + assert_equal Time.utc(2000).hash, ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone["Hawaii"]).hash end def test_plus_with_integer |