diff --git a/localstorage_adapter.js b/localstorage_adapter.js index 0bf218b..5f2ab1b 100644 --- a/localstorage_adapter.js +++ b/localstorage_adapter.js @@ -85,12 +85,9 @@ * @param {Array} payload returned JSONs */ extractArray: function(store, type, payload) { - var serializer = this; - - return payload.map(function(record) { - var extracted = serializer.extractSingle(store, type, record); - return serializer.normalize(type, record); - }); + return payload.map(function(json) { + return this.extractSingle(store, type, json); + }, this); } }); diff --git a/test/tests.js b/test/tests.js index 8249373..7dfefcc 100644 --- a/test/tests.js +++ b/test/tests.js @@ -394,6 +394,29 @@ test("serializeHasMany respects keyForRelationship", function() { deepEqual(json, { ITEMS: ["1"] }); + + store.get('container').unregister('serializer:list') +}); + +test("extractArray calls extractSingle", function() { + var callback = sinon.stub(); + + store.get('container').register('serializer:list', DS.LSSerializer.extend({ + extractSingle: function(store, type, payload) { + callback(); + return this.normalize(type, payload); + } + })); + + expect(1); + stop(); + + store.find('list').then(function(lists) { + equal(callback.callCount, 3); + + start(); + }); + store.get('container').unregister('serializer:list') });