Skip to content

Commit

Permalink
Add failing test for normalizeErrors introduced in PR #2392
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Bourassa committed Jun 10, 2015
1 parent 3d7dba5 commit 393fbf8
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1572,3 +1572,33 @@ test("serializing belongsTo correctly removes embedded foreign key", function()
}
});
});

test('extractErrors extracts embedded errors', function() {
SuperVillain.reopen({
evilMinions: DS.hasMany('secret-weapon', { polymorphic: true })
});

env.registry.register('serializer:super-villain', DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
evilMinions: { embedded: 'always' }
}
}));

var serializer = env.container.lookup('serializer:super-villain');
var payload = {
errors: {
evil_minions: [
{ name: ['required'] }
]
}
};

serializer.extractErrors(env.store, SuperVillain, payload, null); // id (last param) is not relevant here
deepEqual(payload, {
errors: {
evilMinions: [
{ name: ['required'] }
]
}
});
});

0 comments on commit 393fbf8

Please sign in to comment.