@@ -289,6 +289,67 @@ module('integration/serializers/json-api-serializer - JSONAPISerializer', functi
289
289
assert . deepEqual ( user . data . relationships . company . data , { id : '2' , type : 'company' } ) ;
290
290
} ) ;
291
291
292
+ test ( 'Serializer should preserve lid in payloads' , function ( assert ) {
293
+ const store = this . owner . lookup ( 'service:store' ) ;
294
+
295
+ var jsonHash = {
296
+ data : {
297
+ type : 'users' ,
298
+ id : '1' ,
299
+ lid : 'user-1' ,
300
+ attributes : {
301
+ firstname_attribute_key : 'Yehuda' ,
302
+ title_attribute_key : 'director' ,
303
+ } ,
304
+ relationships : {
305
+ company : {
306
+ data : { type : 'companies' , id : '2' , lid : 'company-2' } ,
307
+ } ,
308
+ handles : {
309
+ data : [
310
+ { type : 'github-handles' , id : '3' } ,
311
+ { type : 'twitter-handles' , id : '4' , lid : 'handle-4' } ,
312
+ ] ,
313
+ } ,
314
+ } ,
315
+ included : [
316
+ {
317
+ type : 'companies' ,
318
+ id : '2' ,
319
+ lid : 'company-2' ,
320
+ attributes : {
321
+ name : 'Tilde Inc.' ,
322
+ } ,
323
+ } ,
324
+ {
325
+ type : 'github-handles' ,
326
+ id : '3' ,
327
+ attributes : {
328
+ username : 'wycats' ,
329
+ } ,
330
+ } ,
331
+ {
332
+ type : 'twitter-handles' ,
333
+ id : '4' ,
334
+ lid : 'handle-4' ,
335
+ attributes : {
336
+ nickname : '@wycats' ,
337
+ } ,
338
+ } ,
339
+ ] ,
340
+ } ,
341
+ } ;
342
+
343
+ var user = store . serializerFor ( 'user' ) . normalizeResponse ( store , User , jsonHash , '1' , 'createRecord' ) ;
344
+
345
+ assert . strictEqual ( user . data . lid , 'user-1' ) ;
346
+ assert . deepEqual ( user . data . relationships . company . data , { type : 'company' , id : '2' , lid : 'company-2' } ) ;
347
+ assert . deepEqual ( user . data . relationships . handles . data , [
348
+ { type : 'github-handle' , id : '3' } ,
349
+ { type : 'twitter-handle' , id : '4' , lid : 'handle-4' } ,
350
+ ] ) ;
351
+ } ) ;
352
+
292
353
test ( 'Serializer should respect the attrs hash when serializing attributes and relationships' , function ( assert ) {
293
354
this . owner . register (
294
355
'serializer:user' ,
0 commit comments