diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index 0c45cae4d15..4db47aa8551 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -1874,7 +1874,8 @@ Store = Service.extend({ let operation; if (internalModel.currentState.stateName === 'root.deleted.saved') { - return resolver.resolve(); + resolver.resolve(); + continue; } else if (internalModel.isNew()) { operation = 'createRecord'; } else if (internalModel.isDeleted()) { diff --git a/tests/integration/records/delete-record-test.js b/tests/integration/records/delete-record-test.js index f877e09ca28..a96a7901da6 100644 --- a/tests/integration/records/delete-record-test.js +++ b/tests/integration/records/delete-record-test.js @@ -289,3 +289,29 @@ test("Destroying an invalid newly created record should remove it from the store assert.equal(get(record, 'currentState.stateName'), 'root.deleted.saved'); assert.equal(get(store.peekAll('person'), 'length'), 0, 'The new person should be removed from the store'); }); + +test("Will resolve destroy and save in same loop", function(assert) { + let adam, dave; + let promises; + + assert.expect(1); + + env.adapter.createRecord = function() { + assert.ok(true, 'save operation resolves'); + return Ember.RSVP.Promise.resolve({ id: 123 }); + }; + + run(function() { + adam = env.store.createRecord('person', { name: 'Adam Sunderland' }); + dave = env.store.createRecord('person', { name: 'Dave Sunderland' }); + }); + + run(function() { + promises = [ + adam.destroyRecord(), + dave.save() + ]; + }); + + return Ember.RSVP.all(promises); +});