aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 72b55183ba..04f5ea85a8 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -111,6 +111,13 @@ class TimeWithZoneTest < Test::Unit::TestCase
assert_equal "1999-12-31T19:00:00.123456-05:00", @twz.xmlschema(12)
end
+ def test_xmlschema_with_fractional_seconds_lower_than_hundred_thousand
+ @twz += 0.001234 # advance the time by a fraction
+ assert_equal "1999-12-31T19:00:00.001-05:00", @twz.xmlschema(3)
+ assert_equal "1999-12-31T19:00:00.001234-05:00", @twz.xmlschema(6)
+ assert_equal "1999-12-31T19:00:00.001234-05:00", @twz.xmlschema(12)
+ end
+
def test_to_yaml
assert_match(/^--- 2000-01-01 00:00:00(\.0+)?\s*Z\n/, @twz.to_yaml)
end
@@ -193,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
@@ -434,9 +448,8 @@ class TimeWithZoneTest < Test::Unit::TestCase
end
def test_ruby_19_weekday_name_query_methods
- ruby_19_or_greater = RUBY_VERSION >= '1.9'
%w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name|
- assert_equal ruby_19_or_greater, @twz.respond_to?(name)
+ assert_respond_to @twz, name
end
end