From b6d5ef2b36a913546ee3bb2c15343fc05fa4d97a Mon Sep 17 00:00:00 2001 From: Stanley Stuart Date: Thu, 22 Sep 2016 13:47:36 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"Log=20an=20assertion=20if=20the=20res?= =?UTF-8?q?ponse=20from=20createRecord=20does=20not=20have=20an=20i?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit a67315459dc644af6718c178a0724775c6d3b42d) --- addon/-private/system/store.js | 2 +- tests/integration/adapter/rest-adapter-test.js | 6 +++--- tests/integration/adapter/store-adapter-test.js | 2 +- tests/integration/client-id-generation-test.js | 2 +- tests/integration/relationships/has-many-test.js | 5 +---- tests/integration/store-test.js | 13 ------------- tests/unit/model-test.js | 2 +- 7 files changed, 8 insertions(+), 24 deletions(-) diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index 165f800ac9a..05c92691ebe 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -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); diff --git a/tests/integration/adapter/rest-adapter-test.js b/tests/integration/adapter/rest-adapter-test.js index 47ebc3d3cff..5fa73ba1984 100644 --- a/tests/integration/adapter/rest-adapter-test.js +++ b/tests/integration/adapter/rest-adapter-test.js @@ -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" }); diff --git a/tests/integration/adapter/store-adapter-test.js b/tests/integration/adapter/store-adapter-test.js index 0094d5a7bdd..eec8b75b16b 100644 --- a/tests/integration/adapter/store-adapter-test.js +++ b/tests/integration/adapter/store-adapter-test.js @@ -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(); }); }); diff --git a/tests/integration/client-id-generation-test.js b/tests/integration/client-id-generation-test.js index b98a439db50..72f008b5afa 100644 --- a/tests/integration/client-id-generation-test.js +++ b/tests/integration/client-id-generation-test.js @@ -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() { diff --git a/tests/integration/relationships/has-many-test.js b/tests/integration/relationships/has-many-test.js index 2300815875a..49a46557509 100644 --- a/tests/integration/relationships/has-many-test.js +++ b/tests/integration/relationships/has-many-test.js @@ -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' } @@ -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' } @@ -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(); @@ -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(); } })); diff --git a/tests/integration/store-test.js b/tests/integration/store-test.js index b4fde419326..df4c42e1acc 100644 --- a/tests/integration/store-test.js +++ b/tests/integration/store-test.js @@ -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()); diff --git a/tests/unit/model-test.js b/tests/unit/model-test.js index ea2cc1dc17a..a58452a6537 100644 --- a/tests/unit/model-test.js +++ b/tests/unit/model-test.js @@ -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({