diff options
| author | Soutaro Matsumoto <[email protected]> | 2014-10-29 01:28:52 +0900 |
|---|---|---|
| committer | Soutaro Matsumoto <[email protected]> | 2014-10-29 01:54:39 +0900 |
| commit | 5da13d60508f0ebacb3ba5afd3d29eb00c7ca59e (patch) | |
| tree | 1bb50e72d7d7efc29d83806b51b06e43f59fa827 /test | |
| parent | 7cf747675097be13df633f1b2a5c45391df52b33 (diff) | |
| download | caxlsx-5da13d60508f0ebacb3ba5afd3d29eb00c7ca59e.tar.gz caxlsx-5da13d60508f0ebacb3ba5afd3d29eb00c7ca59e.zip | |
Skip to_time if the value is a Time instance
This skips calling `#to_time` if the value is a instance of subclass of `Time`, like `ActiveSupport::TimeWithZone`.
Diffstat (limited to 'test')
| -rw-r--r-- | test/workbook/worksheet/tc_cell.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index f9761330..5ae2a51f 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -119,6 +119,19 @@ class TestCell < Test::Unit::TestCase assert_equal("2012-10-10T12:24", @c.send(:cast_value, "2012-10-10T12:24")) end + def test_cast_time_subclass + subtime = Class.new(Time) do + def to_time + raise "#to_time of Time subclass should not be called" + end + end + + time = subtime.now + + @c.type = :time + assert_equal(time, @c.send(:cast_value, time)) + end + def test_color assert_raise(ArgumentError) { @c.color = -1.1 } assert_nothing_raised { @c.color = "FF00FF00" } |
