From 43fbe979bab44237583fd7977090b46c24a04d23 Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Wed, 3 Feb 2016 22:28:14 -0600 Subject: [PATCH] Allow 'false' payload to get normalized --- addon/-private/system/store.js | 2 +- tests/unit/store/adapter-interop-test.js | 37 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index f2a44beb630..aa022ad624c 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -2129,7 +2129,7 @@ function _commit(adapter, store, operation, snapshot) { return promise.then((adapterPayload) => { store._adapterRun(() => { var payload, data; - if (adapterPayload) { + if (typeof adapterPayload !== 'undefined') { payload = normalizeResponseHelper(serializer, store, typeClass, adapterPayload, snapshot.id, operation); if (payload.included) { store.push({ data: payload.included }); diff --git a/tests/unit/store/adapter-interop-test.js b/tests/unit/store/adapter-interop-test.js index 24eff8b82b5..008feb34ab7 100644 --- a/tests/unit/store/adapter-interop-test.js +++ b/tests/unit/store/adapter-interop-test.js @@ -276,6 +276,43 @@ test("Find with query calls the correct normalizeResponse", function(assert) { assert.equal(callCount, 1, 'normalizeQueryResponse was called'); }); + +test("Find with query and a response of `false` calls the correct normalizeResponse", function(assert) { + var passedQuery = { page: 1 }; + + var Person = DS.Model.extend({ + name: DS.attr('string') + }); + + var adapter = TestAdapter.extend({ + query(store, type, query) { + return Ember.RSVP.resolve(false); + } + }); + + var callCount = 0; + + var ApplicationSerializer = DS.JSONSerializer.extend({ + normalizeQueryResponse() { + callCount++; + return this._super(...arguments); + } + }); + + var env = setupStore({ + adapter: adapter, + person: Person + }); + var store = env.store; + + env.registry.register('serializer:application', ApplicationSerializer); + + run(function() { + store.query('person', passedQuery); + }); + assert.equal(callCount, 1, 'normalizeQueryResponse was called'); +}); + test("peekAll(type) returns a record array of all records of a specific type", function(assert) { var Person = DS.Model.extend({ name: DS.attr('string')