From 2154a633450f9beaec35580f1314f567aae91738 Mon Sep 17 00:00:00 2001 From: Jimmy Bourassa Date: Tue, 21 Apr 2015 13:46:32 -0400 Subject: [PATCH] Add failing test for `normalizeErrors` introduced in PR #2392 --- .../active-model-serializer-test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/activemodel-adapter/tests/integration/active-model-serializer-test.js b/packages/activemodel-adapter/tests/integration/active-model-serializer-test.js index 53b48bb0718..31fdab67198 100644 --- a/packages/activemodel-adapter/tests/integration/active-model-serializer-test.js +++ b/packages/activemodel-adapter/tests/integration/active-model-serializer-test.js @@ -341,3 +341,21 @@ test("extractErrors camelizes keys", function() { firstName: ["firstName not evil enough"] }); }); + +test('extractErrors extracts polymorphic records errors', function() { + var payload = { + errors: { + evil_minions: [ + { name: ['required'] } + ] + } + }; + + var serializer = env.container.lookup('serializer:application'); + // note: id (last param) is not relevant here + var extractedErrors = serializer.extractErrors(env.store, MediocreVillain, payload, null); + + deepEqual(extractedErrors, { + evilMinions: [{ name: ['required'] }] + }); +});