File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ def serialize_cast_value(value) # :nodoc:
47
47
def serializable? ( value , &_ )
48
48
true
49
49
end
50
+
51
+ private
52
+ def max_value
53
+ ::Float ::INFINITY
54
+ end
50
55
end
51
56
end
52
57
end
Original file line number Diff line number Diff line change 5
5
module ActiveModel
6
6
module Type
7
7
class BigIntegerTest < ActiveModel ::TestCase
8
+ class CustomNumber
9
+ attr_reader :num
10
+
11
+ def initialize ( num )
12
+ @num = num
13
+ end
14
+
15
+ alias_method :to_i , :num
16
+ end
17
+
8
18
def test_type_cast_big_integer
9
19
type = Type ::BigInteger . new
10
20
assert_equal 1 , type . cast ( 1 )
@@ -21,6 +31,13 @@ def test_large_values
21
31
assert_equal 9999999999999999999999999999999 , type . serialize ( 9999999999999999999999999999999 )
22
32
end
23
33
34
+ def test_integer_like_classes_that_are_greater_than_4_bytes_still_serialize
35
+ type = Type ::BigInteger . new
36
+ large_number = 9999999999999999999999999999999
37
+
38
+ assert_equal large_number , type . serialize ( CustomNumber . new ( large_number ) )
39
+ end
40
+
24
41
test "serialize_cast_value is equivalent to serialize after cast" do
25
42
type = Type ::BigInteger . new
26
43
value = type . cast ( 9999999999999999999999999999999 )
You can’t perform that action at this time.
0 commit comments