Skip to content

Commit

Permalink
Merge pull request locks#69 from fsmanuel/fix-extract-array
Browse files Browse the repository at this point in the history
fix extractArray
  • Loading branch information
kurko committed Aug 16, 2014
2 parents 21b25aa + 1474e2e commit b60c486
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
9 changes: 3 additions & 6 deletions localstorage_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,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);
}

});
Expand Down
22 changes: 22 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,28 @@ test('saves hasMany', function() {
});
});

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')
});

// This crashes chrome.
// TODO: Figure out a way to test this without using so much memory.
//
Expand Down

0 comments on commit b60c486

Please sign in to comment.