Skip to content

Commit

Permalink
Allow 'false' payload to get normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
meirish committed Feb 4, 2016
1 parent 567dfc5 commit 43fbe97
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/store/adapter-interop-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 43fbe97

Please sign in to comment.