@@ -42,6 +42,15 @@ let expectedCreatePayload = {
4242 method : 'create'
4343 }
4444 ]
45+ } ,
46+ special_books : {
47+ data : [
48+ {
49+ [ 'temp-id' ] : 'abc3' ,
50+ type : 'books' ,
51+ method : 'create'
52+ }
53+ ]
4554 }
4655 }
4756 } ,
@@ -68,6 +77,13 @@ let expectedCreatePayload = {
6877 attributes : {
6978 name : 'Horror'
7079 }
80+ } ,
81+ {
82+ [ 'temp-id' ] : 'abc3' ,
83+ type : 'books' ,
84+ attributes : {
85+ title : 'The Stand'
86+ }
7187 }
7288 ]
7389} ;
@@ -122,8 +138,11 @@ const seedPersistedData = function() {
122138 genre . isPersisted ( true ) ;
123139 let book = new Book ( { id : '10' , title : 'The Shining' , genre : genre } ) ;
124140 book . isPersisted ( true ) ;
141+ let specialBook = new Book ( { id : '30' , title : 'The Stand' } ) ;
142+ specialBook . isPersisted ( true ) ;
125143 instance . id = '1' ;
126144 instance . books = [ book ] ;
145+ instance . specialBooks = [ specialBook ] ;
127146 instance . isPersisted ( true ) ;
128147 genre . name = 'Updated Genre Name' ;
129148 book . title = 'Updated Book Title' ;
@@ -169,6 +188,12 @@ describe('nested persistence', function() {
169188 id : '20' ,
170189 type : 'genres' ,
171190 attributes : { name : 'name from server' }
191+ } ,
192+ {
193+ [ 'temp-id' ] : 'abc3' ,
194+ id : '30' ,
195+ type : 'books' ,
196+ attributes : { title : 'another title from server' }
172197 }
173198 ]
174199 }
@@ -199,14 +224,16 @@ describe('nested persistence', function() {
199224 beforeEach ( function ( ) {
200225 let genre = new Genre ( { name : 'Horror' } ) ;
201226 let book = new Book ( { title : 'The Shining' , genre : genre } ) ;
227+ let specialBook = new Book ( { title : 'The Stand' } ) ;
202228 instance . books = [ book ] ;
229+ instance . specialBooks = [ specialBook ] ;
203230 } ) ;
204231
205232 // todo test on the way back - id set, attrs updated, isPersisted
206233 // todo remove #destroy? and just save when markwithpersisted? combo? for ombined payload
207234 // todo test unique includes/circular relationshio
208235 it ( 'sends the correct payload' , function ( done ) {
209- instance . save ( { with : { books : 'genre' } } ) . then ( ( response ) => {
236+ instance . save ( { with : { books : 'genre' , specialBooks : { } } } ) . then ( ( response ) => {
210237 expect ( payloads [ 0 ] ) . to . deep . equal ( expectedCreatePayload ) ;
211238 done ( ) ;
212239 } ) ;
0 commit comments