@@ -42,6 +42,15 @@ let expectedCreatePayload = {
42
42
method : 'create'
43
43
}
44
44
]
45
+ } ,
46
+ special_books : {
47
+ data : [
48
+ {
49
+ [ 'temp-id' ] : 'abc3' ,
50
+ type : 'books' ,
51
+ method : 'create'
52
+ }
53
+ ]
45
54
}
46
55
}
47
56
} ,
@@ -68,6 +77,13 @@ let expectedCreatePayload = {
68
77
attributes : {
69
78
name : 'Horror'
70
79
}
80
+ } ,
81
+ {
82
+ [ 'temp-id' ] : 'abc3' ,
83
+ type : 'books' ,
84
+ attributes : {
85
+ title : 'The Stand'
86
+ }
71
87
}
72
88
]
73
89
} ;
@@ -122,8 +138,11 @@ const seedPersistedData = function() {
122
138
genre . isPersisted ( true ) ;
123
139
let book = new Book ( { id : '10' , title : 'The Shining' , genre : genre } ) ;
124
140
book . isPersisted ( true ) ;
141
+ let specialBook = new Book ( { id : '30' , title : 'The Stand' } ) ;
142
+ specialBook . isPersisted ( true ) ;
125
143
instance . id = '1' ;
126
144
instance . books = [ book ] ;
145
+ instance . specialBooks = [ specialBook ] ;
127
146
instance . isPersisted ( true ) ;
128
147
genre . name = 'Updated Genre Name' ;
129
148
book . title = 'Updated Book Title' ;
@@ -169,6 +188,12 @@ describe('nested persistence', function() {
169
188
id : '20' ,
170
189
type : 'genres' ,
171
190
attributes : { name : 'name from server' }
191
+ } ,
192
+ {
193
+ [ 'temp-id' ] : 'abc3' ,
194
+ id : '30' ,
195
+ type : 'books' ,
196
+ attributes : { title : 'another title from server' }
172
197
}
173
198
]
174
199
}
@@ -199,14 +224,16 @@ describe('nested persistence', function() {
199
224
beforeEach ( function ( ) {
200
225
let genre = new Genre ( { name : 'Horror' } ) ;
201
226
let book = new Book ( { title : 'The Shining' , genre : genre } ) ;
227
+ let specialBook = new Book ( { title : 'The Stand' } ) ;
202
228
instance . books = [ book ] ;
229
+ instance . specialBooks = [ specialBook ] ;
203
230
} ) ;
204
231
205
232
// todo test on the way back - id set, attrs updated, isPersisted
206
233
// todo remove #destroy? and just save when markwithpersisted? combo? for ombined payload
207
234
// todo test unique includes/circular relationshio
208
235
it ( 'sends the correct payload' , function ( done ) {
209
- instance . save ( { with : { books : 'genre' } } ) . then ( ( response ) => {
236
+ instance . save ( { with : { books : 'genre' , specialBooks : { } } } ) . then ( ( response ) => {
210
237
expect ( payloads [ 0 ] ) . to . deep . equal ( expectedCreatePayload ) ;
211
238
done ( ) ;
212
239
} ) ;
0 commit comments