Permalink
Browse files

TimeWithZone.name returns 'Time', to further thwart type checking

  • Loading branch information...
1 parent 70de8e6 commit c00f2d25de640b8de1c8583474085f3836ee1768 @gbuesing gbuesing committed Apr 5, 2009
View
@@ -1,5 +1,7 @@
*Edge
+* TimeWithZone.name returns 'Time', to further thwart type checking [Geoff Buesing]
+
* Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day #2066 [Michael Curtis]
@@ -31,6 +31,11 @@ module ActiveSupport
# t.is_a?(Time) # => true
# t.is_a?(ActiveSupport::TimeWithZone) # => true
class TimeWithZone
+
+ def self.name
+ 'Time' # Report class name as 'Time' to thwart type checking
+ end
+
include Comparable
attr_reader :time_zone
@@ -317,6 +317,10 @@ def test_is_a
assert @twz.kind_of?(Time)
assert @twz.is_a?(ActiveSupport::TimeWithZone)
end
+
+ def test_class_name
+ assert_equal 'Time', ActiveSupport::TimeWithZone.name
+ end
def test_method_missing_with_time_return_value
assert_instance_of ActiveSupport::TimeWithZone, @twz.months_since(1)

0 comments on commit c00f2d2

Please sign in to comment.