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)
54
54
55
55
def json_ids ( integers = false )
56
56
ids = json [ 'data' ] . map { |d | d [ 'id' ] }
57
- ids . map! ( & :to_i ) if integers
57
+ ids . map! { | id | Integer ( id ) } if integers
58
58
ids
59
59
end
60
60
Original file line number Diff line number Diff line change 150
150
expect ( json_ids ( true ) ) . to eq ( [ 1 , 2 ] )
151
151
end
152
152
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
153
176
end
154
177
155
178
describe '#json_included_types' do
You can’t perform that action at this time.
0 commit comments