From 6951988784d05e33b2be052a759a286bb10a9066 Mon Sep 17 00:00:00 2001 From: GCorbel Date: Tue, 22 Dec 2015 06:40:14 -0500 Subject: [PATCH] Use keyForReliationship for belongsTo and hasMany --- addon/-private/serializers/embedded-records-mixin.js | 4 ++-- tests/integration/serializers/embedded-records-mixin-test.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/-private/serializers/embedded-records-mixin.js b/addon/-private/serializers/embedded-records-mixin.js index accf903c404..2d231921ad6 100644 --- a/addon/-private/serializers/embedded-records-mixin.js +++ b/addon/-private/serializers/embedded-records-mixin.js @@ -217,7 +217,7 @@ export default Ember.Mixin.create({ _serializeEmbeddedBelongsTo(snapshot, json, relationship) { let embeddedSnapshot = snapshot.belongsTo(relationship.key); - let serializedKey = this.keyForAttribute(relationship.key, 'serialize'); + let serializedKey = this.keyForRelationship(relationship.key, 'serialize'); if (!embeddedSnapshot) { json[serializedKey] = null; } else { @@ -332,7 +332,7 @@ export default Ember.Mixin.create({ }, _serializeEmbeddedHasMany(snapshot, json, relationship) { - let serializedKey = this.keyForAttribute(relationship.key, 'serialize'); + let serializedKey = this.keyForRelationship(relationship.key, 'serialize'); warn( `The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`, diff --git a/tests/integration/serializers/embedded-records-mixin-test.js b/tests/integration/serializers/embedded-records-mixin-test.js index c2122b0e1c0..4a7691cac1a 100644 --- a/tests/integration/serializers/embedded-records-mixin-test.js +++ b/tests/integration/serializers/embedded-records-mixin-test.js @@ -910,7 +910,7 @@ test("serialize with embedded objects and a custom keyForAttribute (hasMany rela }); env.registry.register('serializer:home-planet', DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { - keyForAttribute(key) { + keyForRelationship(key) { return key + '-custom'; }, attrs: { @@ -926,7 +926,7 @@ test("serialize with embedded objects and a custom keyForAttribute (hasMany rela }); assert.deepEqual(json, { - "name-custom": "Villain League", + "name": "Villain League", "villains-custom": [{ id: get(tom, "id"), firstName: "Tom",