Skip to content

Commit

Permalink
Revert "Log an assertion if the response from createRecord does not h…
Browse files Browse the repository at this point in the history
…ave an i…"

(cherry picked from commit a673154)
  • Loading branch information
fivetanley authored and bmac committed Sep 23, 2016
1 parent db947b8 commit b6d5ef2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ Store = Service.extend({
this._backburner.schedule('normalizeRelationships', this, '_setupRelationships', internalModel, data);
this.updateId(internalModel, data);
}
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
6 changes: 3 additions & 3 deletions tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ test("createRecord - a serializer's primary key and attributes are consulted whe
test("createRecord - a serializer's attributes are consulted when building the payload if no id is pre-defined", function(assert) {
var post;
env.registry.register('serializer:post', DS.RESTSerializer.extend({
primarykey: '_id_',

attrs: {
name: '_name_'
}
}));

ajaxResponse({
post: { '_name_': "The Parley Letter", id: '1' }
});
ajaxResponse();

run(function() {
post = store.createRecord('post', { name: "The Parley Letter" });
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/adapter/store-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ test("createRecord receives a snapshot", function(assert) {
var person;

run(function() {
person = store.createRecord('person', { name: "Tom Dale", id: 1 });
person = store.createRecord('person', { name: "Tom Dale" });
person.save();
});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/client-id-generation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test("empty string and undefined ids should coerce to null", function(assert) {

env.adapter.createRecord = function(store, type, record) {
assert.equal(typeof get(record, 'id'), 'object', 'correct type');
return Ember.RSVP.resolve({ id: 1 });
return Ember.RSVP.resolve();
};

run(function() {
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/relationships/has-many-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ test("A hasMany updated link should not remove new children", function(assert) {

env.adapter.createRecord = function(store, snapshot, link, relationship) {
return Ember.RSVP.resolve({
id: 1,
links: {
comments: '/some/link'
}
Expand Down Expand Up @@ -383,7 +382,6 @@ test("A hasMany updated link should not remove new children when the parent reco

env.adapter.createRecord = function(store, snapshot, link, relationship) {
return Ember.RSVP.resolve({
id: 1,
links: {
comments: '/some/link'
}
Expand Down Expand Up @@ -2209,7 +2207,6 @@ test("adding and removing records from hasMany relationship #2666", function(ass
})
});

var commentId = 4;
env.registry.register('adapter:comment', DS.RESTAdapter.extend({
deleteRecord(record) {
return Ember.RSVP.resolve();
Expand All @@ -2218,7 +2215,7 @@ test("adding and removing records from hasMany relationship #2666", function(ass
return Ember.RSVP.resolve();
},
createRecord() {
return Ember.RSVP.resolve({ comments: { id: commentId++ }});
return Ember.RSVP.resolve();
}
}));

Expand Down
13 changes: 0 additions & 13 deletions tests/integration/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,19 +867,6 @@ testInDebug('store#findRecord that returns an array should assert', assert => {
}, /expected the primary data returned from a `findRecord` response to be an object but instead it found an array/);
});

testInDebug('store#didSaveRecord should assert when the response to a save does not include the id', function(assert) {
env.adapter.createRecord = function() {
return {};
};

assert.expectAssertion(function() {
run(function() {
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/);
});

module("integration/store - queryRecord", {
beforeEach() {
initializeStore(DS.Adapter.extend());
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ test("changedAttributes() works while the record is being saved", function(asser
assert.deepEqual(toObj(cat.changedAttributes()), {
name: [undefined, 'Argon'],
likes: [undefined, 'Cheese'] });
return { id: 1 };
return {};
}
});
var Mascot = DS.Model.extend({
Expand Down

0 comments on commit b6d5ef2

Please sign in to comment.