File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def json_include(type, index = 0)
5454
5555 def json_ids ( integers = false )
5656 ids = json [ 'data' ] . map { |d | d [ 'id' ] }
57- ids . map! ( & :to_i ) if integers
57+ ids . map! { | id | Integer ( id ) } if integers
5858 ids
5959 end
6060
Original file line number Diff line number Diff line change 150150 expect ( json_ids ( true ) ) . to eq ( [ 1 , 2 ] )
151151 end
152152 end
153+
154+ context 'when ids are non-integers' do
155+ let ( :index_json ) do
156+ {
157+ 'data' => [
158+ {
159+ 'type' => 'posts' ,
160+ 'id' => 'ABC123' ,
161+ 'attributes' => { }
162+ } ,
163+ {
164+ 'type' => 'posts' ,
165+ 'id' => 'KTHXBBQ' ,
166+ 'attributes' => { }
167+ }
168+ ]
169+ }
170+ end
171+
172+ it 'fails loudly when trying to cast to integers' do
173+ expect { json_ids ( true ) } . to raise_error ArgumentError
174+ end
175+ end
153176 end
154177
155178 describe '#json_included_types' do
You can’t perform that action at this time.
0 commit comments