@@ -161,53 +161,46 @@ class UtilTest < Test::Unit::TestCase
161161 context "#objects_to_ids" do
162162 should "convert APIResource to id" do
163163 resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
164- result = Util . objects_to_ids ( resource , :v1 )
164+ result = Util . objects_to_ids ( resource )
165165 assert_equal "ch_123" , result
166166 end
167167
168168 should "pass through primitives unchanged" do
169- assert_equal "string" , Util . objects_to_ids ( "string" , :v1 )
170- assert_equal 123 , Util . objects_to_ids ( 123 , :v1 )
171- assert_equal true , Util . objects_to_ids ( true , :v1 )
169+ assert_equal "string" , Util . objects_to_ids ( "string" )
170+ assert_equal 123 , Util . objects_to_ids ( 123 )
171+ assert_equal true , Util . objects_to_ids ( true )
172172 end
173173
174- should "skip nil values in hashes with v1 semantics " do
174+ should "skip nil values in hashes by default " do
175175 input = { a : "value" , b : nil , c : "another" }
176- result = Util . objects_to_ids ( input , :v1 )
176+ result = Util . objects_to_ids ( input )
177177 assert_equal ( { a : "value" , c : "another" } , result )
178178 refute result . key? ( :b )
179179 end
180180
181- should "keep nil values in hashes with v2 semantics " do
181+ should "keep nil values in hashes when serialize_empty is true " do
182182 input = { a : "value" , b : nil , c : "another" }
183- result = Util . objects_to_ids ( input , :v2 )
183+ result = Util . objects_to_ids ( input , serialize_empty : true )
184184 assert_equal ( { a : "value" , b : nil , c : "another" } , result )
185185 assert result . key? ( :b )
186186 assert_nil result [ :b ]
187187 end
188188
189- should "recurse on non-nil hash values with v1 semantics " do
189+ should "recurse on non-nil hash values" do
190190 resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
191191 input = { charge : resource , amount : 100 }
192- result = Util . objects_to_ids ( input , :v1 )
192+ result = Util . objects_to_ids ( input )
193193 assert_equal ( { charge : "ch_123" , amount : 100 } , result )
194194 end
195195
196- should "recurse on non-nil hash values with v2 semantics" do
197- resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
198- input = { charge : resource , amount : 100 }
199- result = Util . objects_to_ids ( input , :v2 )
200- assert_equal ( { charge : "ch_123" , amount : 100 } , result )
201- end
202-
203- should "handle nested hashes with nil values in v1 semantics" do
196+ should "handle nested hashes with nil values by default" do
204197 resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
205198 input = {
206199 charge : resource ,
207200 metadata : { key : "value" , empty : nil } ,
208201 description : nil ,
209202 }
210- result = Util . objects_to_ids ( input , :v1 )
203+ result = Util . objects_to_ids ( input )
211204 expected = {
212205 charge : "ch_123" ,
213206 metadata : { key : "value" } ,
@@ -217,14 +210,14 @@ class UtilTest < Test::Unit::TestCase
217210 refute result . key? ( :description )
218211 end
219212
220- should "handle nested hashes with nil values in v2 semantics " do
213+ should "handle nested hashes with nil values when serialize_empty is true " do
221214 resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
222215 input = {
223216 charge : resource ,
224217 metadata : { key : "value" , empty : nil } ,
225218 description : nil ,
226219 }
227- result = Util . objects_to_ids ( input , :v2 )
220+ result = Util . objects_to_ids ( input , serialize_empty : true )
228221 expected = {
229222 charge : "ch_123" ,
230223 metadata : { key : "value" , empty : nil } ,
@@ -235,43 +228,35 @@ class UtilTest < Test::Unit::TestCase
235228 assert result . key? ( :description )
236229 end
237230
238- should "process arrays with v1 semantics" do
239- resource1 = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
240- resource2 = Stripe ::Charge . construct_from ( id : "ch_456" , object : "charge" )
241- input = [ resource1 , "string" , resource2 ]
242- result = Util . objects_to_ids ( input , :v1 )
243- assert_equal %w[ ch_123 string ch_456 ] , result
244- end
245-
246- should "process arrays with v2 semantics" do
231+ should "process arrays" do
247232 resource1 = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
248233 resource2 = Stripe ::Charge . construct_from ( id : "ch_456" , object : "charge" )
249234 input = [ resource1 , "string" , resource2 ]
250- result = Util . objects_to_ids ( input , :v2 )
235+ result = Util . objects_to_ids ( input )
251236 assert_equal %w[ ch_123 string ch_456 ] , result
252237 end
253238
254- should "handle complex nested structures with v1 semantics " do
239+ should "handle complex nested structures by default " do
255240 resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
256241 input = {
257242 charges : [ resource , nil ] ,
258243 metadata : { key : nil , nested : { value : "test" , empty : nil } } ,
259244 }
260- result = Util . objects_to_ids ( input , :v1 )
245+ result = Util . objects_to_ids ( input )
261246 expected = {
262247 charges : [ "ch_123" , nil ] ,
263248 metadata : { nested : { value : "test" } } ,
264249 }
265250 assert_equal expected , result
266251 end
267252
268- should "handle complex nested structures with v2 semantics " do
253+ should "handle complex nested structures when serialize_empty is true " do
269254 resource = Stripe ::Charge . construct_from ( id : "ch_123" , object : "charge" )
270255 input = {
271256 charges : [ resource , nil ] ,
272257 metadata : { key : nil , nested : { value : "test" , empty : nil } } ,
273258 }
274- result = Util . objects_to_ids ( input , :v2 )
259+ result = Util . objects_to_ids ( input , serialize_empty : true )
275260 expected = {
276261 charges : [ "ch_123" , nil ] ,
277262 metadata : { key : nil , nested : { value : "test" , empty : nil } } ,
0 commit comments