diff --git a/addon/system/store/finders.js b/addon/system/store/finders.js index d4455f2effd..b08fa06bbba 100644 --- a/addon/system/store/finders.js +++ b/addon/system/store/finders.js @@ -190,6 +190,7 @@ export function _queryRecord(adapter, store, typeClass, query) { var record; store._adapterRun(function() { var payload = normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'queryRecord'); + Ember.assert('`store.queryRecord` expected the adapter to return one record but the response from the adapter was empty.', payload.data); //TODO Optimize record = store.push(payload); }); diff --git a/tests/integration/adapter/rest-adapter-test.js b/tests/integration/adapter/rest-adapter-test.js index de6fefa4afc..c4583c57add 100644 --- a/tests/integration/adapter/rest-adapter-test.js +++ b/tests/integration/adapter/rest-adapter-test.js @@ -1325,6 +1325,18 @@ test("queryRecord - returning an array picks the first one but saves all records })); }); +test("queryRecord - returning an empty array errors", function(assert) { + ajaxResponse({ + post: [] + }); + + assert.expectAssertion(function() { + Ember.run(function() { + store.queryRecord('post', { slug: 'rails-is-omakaze' }); + }); + }, /`store.queryRecord` expected the adapter to return one record/); +}); + test("queryRecord - data is normalized through custom serializers", function(assert) { env.registry.register('serializer:post', DS.RESTSerializer.extend({ primaryKey: '_ID_',