File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/integration/adapters Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,27 @@ test('create a new record', function (assert) {
263
263
} ) . finally ( done ) ;
264
264
} ) ;
265
265
266
+ test ( 'update a newly created record before it has finished saving' , function ( assert ) {
267
+ assert . expect ( 2 ) ;
268
+
269
+ const done = assert . async ( ) ;
270
+ Promise . resolve ( ) . then ( ( ) => {
271
+ var newSoup = this . store ( ) . createRecord ( 'taco-soup' , { id : 'E' , flavor : 'oops-wrong-flavor' } ) ;
272
+ newSoup . save ( ) ;
273
+ newSoup . set ( 'flavor' , 'balsamic' ) ;
274
+ return newSoup . save ( ) ;
275
+ } ) . then ( ( ) => {
276
+ return this . db ( ) . get ( 'tacoSoup_2_E' ) ;
277
+ } ) . then ( ( newDoc ) => {
278
+ assert . equal ( newDoc . data . flavor , 'balsamic' , 'should have saved the attribute' ) ;
279
+
280
+ var recordInStore = this . store ( ) . peekRecord ( 'tacoSoup' , 'E' ) ;
281
+ assert . equal ( newDoc . _rev , recordInStore . get ( 'rev' ) ,
282
+ 'should have associated the ember-data record with the rev for the new record' ) ;
283
+
284
+ } ) . finally ( done ) ;
285
+ } ) ;
286
+
266
287
test ( 'creating an associated record stores a reference to it in the parent' , function ( assert ) {
267
288
assert . expect ( 1 ) ;
268
289
You can’t perform that action at this time.
0 commit comments