Permalink
Browse files

Merge pull request #2801 from jeremyevans/patch-1

Fix obviously breakage of Time.=== for Time subclasses
  • Loading branch information...
2 parents e141cbd + da8f00a commit c10fcd26376d9cdc4d4a27b66271ab33413ca18f @jeremy jeremy committed Oct 3, 2011
@@ -9,7 +9,7 @@ class Time
class << self
# Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances
def ===(other)
- other.is_a?(::Time)
+ super || (self == Time && other.is_a?(ActiveSupport::TimeWithZone))
end
# Return the number of days in the given month.
@@ -764,7 +764,10 @@ def test_time_created_with_local_constructor_cannot_represent_times_during_hour_
def test_case_equality
assert Time === Time.utc(2000)
assert Time === ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone['UTC'])
+ assert Time === Class.new(Time).utc(2000)
assert_equal false, Time === DateTime.civil(2000)
+ assert_equal false, Class.new(Time) === Time.utc(2000)
+ assert_equal false, Class.new(Time) === ActiveSupport::TimeWithZone.new(Time.utc(2000), ActiveSupport::TimeZone['UTC'])
end
def test_all_day

0 comments on commit c10fcd2

Please sign in to comment.