Skip to content

Commit

Permalink
fix assertion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Oct 17, 2016
1 parent 58baca4 commit 2d464dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ Store = Service.extend({
} else {
assert(`Your ${internalModel.type.modelName} record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response.`, internalModel.id);
}
assert(`Your ${internalModel.type.modelName} record was saved but it does not have an id. Please make the server provides an id in the createRecord response or you are setting the on the client side before saving the record.`, internalModel.id !== null);

//We first make sure the primary data has been updated
//TODO try to move notification to the user to the end of the runloop
internalModel.adapterDidCommit(data);
Expand Down Expand Up @@ -1810,10 +1810,10 @@ Store = Service.extend({
var id = coerceId(data.id);

// ID absolutely can't be missing if the oldID is empty (missing Id in response for a new record)
assert(`The store cannot assign an empty id to record '${internalModel.type.modelName}:${internalModel[GUID_KEY]}', because it already has an empty ID.`, id !== null && oldId !== null);
assert(`'${internalModel.type.modelName}:${internalModel[GUID_KEY]}' was saved to the server, but the response does not have an id and your record does not either.`, !(id === null && oldId === null));

// ID absolutely can't be different than oldID if oldID is not null
assert("The store cannot assign a new id to a record that already has an id. " + internalModel + " had id: " + oldId + " and you tried to update it with " + id + ". This likely happened because your server returned data in response to a find or update that had a different id than the one you sent.", oldId !== null && id === oldId);
assert(`'${internalModel.type.modelName}:${oldId}' was saved to the server, but the response returned the new id '${id}'. The store cannot assign a new id to a record that already has an id.`, !(oldId !== null && id !== oldId));

// ID can be null if oldID is not null (altered ID in response for a record)
// however, this is more than likely a developer error.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ testInDebug('store#didSaveRecord should assert when the response to a save does
var car = store.createRecord('car');
car.save();
});
}, /record was saved but it does not have an id. Please make the server provides an id in the createRecord/);
}, /Your car record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response./);
});

module("integration/store - queryRecord", {
Expand Down

0 comments on commit 2d464dc

Please sign in to comment.