Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into fix-serialize-has-many
Browse files Browse the repository at this point in the history
Conflicts:
	test/tests.js
  • Loading branch information
fsmanuel committed Aug 16, 2014
2 parents cb50189 + b60c486 commit 16522c2
Show file tree
Hide file tree
Showing 2 changed files with 26 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 @@ -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);
}

});
Expand Down
23 changes: 23 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
});

Expand Down

0 comments on commit 16522c2

Please sign in to comment.