Skip to content

Commit

Permalink
Merge pull request #3040 from pangratz/extractErrors_respects_custom_…
Browse files Browse the repository at this point in the history
…key_mappings

JSONSerializer#extractErrors respects custom key mappings
  • Loading branch information
igorT committed May 4, 2015
2 parents 2f2f8a9 + a879173 commit f129656
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ember-data/lib/serializers/json-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export default Serializer.extend({
this.normalizeId(hash);
this.normalizeAttributes(typeClass, hash);
this.normalizeRelationships(typeClass, hash);
this.normalizeUsingDeclaredMapping(typeClass, hash);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,26 @@ test('serializeBelongsTo with async polymorphic', function() {

deepEqual(json, expected, 'returned JSON is correct');
});

test('extractErrors respects custom key mappings', function() {
env.registry.register('serializer:post', DS.JSONSerializer.extend({
attrs: {
title: 'le_title',
comments: { key: 'my_comments' }
}
}));

var payload = {
errors: {
le_title: ["title errors"],
my_comments: ["comments errors"]
}
};

var errors = env.container.lookup('serializer:post').extractErrors(env.store, Post, payload);

deepEqual(errors, {
title: ["title errors"],
comments: ["comments errors"]
});
});

0 comments on commit f129656

Please sign in to comment.