提交 c00f2d25 编写于 作者: G Geoff Buesing

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

上级 70de8e64
*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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册