@@ -22,6 +22,9 @@ class Director < BaseResource
2222 has_many :movies
2323end
2424
25+
26+ NUMERIC_ASSERTION = Gem ::Version . new ( RUBY_VERSION ) < Gem ::Version . new ( '2.4' ) ? Fixnum : Integer
27+
2528class IntegerIdTestAssociationTest < MiniTest ::Test
2629
2730 def test_included_document_test_id_from_method_as_integer
@@ -66,12 +69,12 @@ def test_included_document_test_id_from_method_as_integer
6669 ]
6770 } . to_json )
6871 movie = Movie . includes ( :actor ) . find ( 1 ) . last
69- assert_equal ( Integer , movie . id . class )
72+ assert_equal ( NUMERIC_ASSERTION , movie . id . class )
7073 assert_equal ( 1 , movie . id )
7174 assert_equal ( String , movie . attributes [ :id ] . class )
7275 assert_equal ( '1' , movie . attributes [ :id ] )
7376 assert_equal ( Actor , movie . actor . class )
74- assert_equal ( Integer , movie . actor . id . class )
77+ assert_equal ( NUMERIC_ASSERTION , movie . actor . id . class )
7578 assert_equal ( 1 , movie . actor . id )
7679 assert_equal ( '1' , movie . actor . attributes [ :id ] )
7780 assert_equal ( movie . actor_id , movie . actor . id )
@@ -107,7 +110,7 @@ def test_not_included_data_document
107110 }
108111 } . to_json )
109112 movie = Movie . find ( 1 ) . last
110- assert_equal ( Integer , movie . id . class )
113+ assert_equal ( NUMERIC_ASSERTION , movie . id . class )
111114 assert_equal ( 1 , movie . id )
112115 assert_equal ( String , movie . attributes [ :id ] . class )
113116 assert_equal ( '1' , movie . attributes [ :id ] )
@@ -172,7 +175,7 @@ def test_not_included_data_document_with_relationships_links
172175 }
173176 } . to_json )
174177 movie = Movie . find ( 1 ) . last
175- assert_equal ( Integer , movie . id . class )
178+ assert_equal ( NUMERIC_ASSERTION , movie . id . class )
176179 assert_equal ( 1 , movie . id )
177180 assert_equal ( String , movie . attributes [ :id ] . class )
178181 assert_equal ( '1' , movie . attributes [ :id ] )
0 commit comments