diff --git a/addon/serializers/rest.js b/addon/serializers/rest.js index f10533fd614..3291dcbb7ff 100644 --- a/addon/serializers/rest.js +++ b/addon/serializers/rest.js @@ -160,16 +160,6 @@ const RESTSerializer = JSONSerializer.extend({ @param {String} prop @return {Object} */ - normalize(modelClass, resourceHash, prop) { - if (this.normalizeHash && this.normalizeHash[prop]) { - deprecate('`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.', false, { - id: 'ds.serializer.normalize-hash-deprecated', - until: '3.0.0' - }); - this.normalizeHash[prop](resourceHash); - } - return this._super(modelClass, resourceHash); - }, /** Normalizes an array of resource payloads and returns a JSON-API Document diff --git a/tests/integration/serializers/rest-serializer-test.js b/tests/integration/serializers/rest-serializer-test.js index f2aca2c68ae..584d2b6661c 100644 --- a/tests/integration/serializers/rest-serializer-test.js +++ b/tests/integration/serializers/rest-serializer-test.js @@ -374,116 +374,6 @@ test("normalizeResponse loads secondary records with correct serializer", functi assert.equal(superVillainNormalizeCount, 1, "superVillain is normalized once"); }); -testInDebug('normalizeHash normalizes specific parts of the payload (DEPRECATED)', function(assert) { - env.registry.register('serializer:application', DS.RESTSerializer.extend({ - normalizeHash: { - homePlanets(hash) { - hash.id = hash._id; - delete hash._id; - return hash; - } - } - })); - - var jsonHash = { - homePlanets: [{ _id: "1", name: "Umber", superVillains: [1] }] - }; - var array; - - run(function() { - assert.expectDeprecation(function() { - array = env.restSerializer.normalizeResponse(env.store, HomePlanet, jsonHash, null, 'findAll'); - }, /`RESTSerializer.normalizeHash` has been deprecated/); - }); - - assert.deepEqual(array, { - "data": [{ - "id": "1", - "type": "home-planet", - "attributes": { - "name": "Umber" - }, - "relationships": { - "superVillains": { - "data": [ - { "id": "1", "type": "super-villain" } - ] - } - } - }], - "included": [] - }); - -}); - -testInDebug('normalizeHash has been deprecated', function(assert) { - env.registry.register('serializer:application', DS.RESTSerializer.extend({ - - normalizeHash: { - homePlanets(hash) { - hash.id = hash._id; - delete hash._id; - return hash; - } - } - })); - - var jsonHash = { - homePlanets: [{ _id: "1", name: "Umber", superVillains: [1] }] - }; - - run(function() { - assert.expectDeprecation(function() { - env.restSerializer.normalizeResponse(env.store, HomePlanet, jsonHash, null, 'findAll'); - }, /`RESTSerializer.normalizeHash` has been deprecated/); - }); -}); - - -testInDebug('normalizeHash works with transforms (DEPRECATED)', function(assert) { - env.registry.register('serializer:application', DS.RESTSerializer.extend({ - normalizeHash: { - evilMinions(hash) { - hash.condition = hash._condition; - delete hash._condition; - return hash; - } - } - })); - - env.registry.register('transform:condition', DS.Transform.extend({ - deserialize(serialized) { - if (serialized === 1) { - return "healing"; - } else { - return "unknown"; - } - }, - serialize(deserialized) { - if (deserialized === "healing") { - return 1; - } else { - return 2; - } - } - })); - - EvilMinion.reopen({ condition: DS.attr('condition') }); - - var jsonHash = { - evilMinions: [{ id: "1", name: "Tom Dale", superVillain: 1, _condition: 1 }] - }; - var array; - - run(function() { - assert.expectDeprecation(function() { - array = env.restSerializer.normalizeResponse(env.store, EvilMinion, jsonHash, null, 'findAll'); - }, /`RESTSerializer.normalizeHash` has been deprecated/); - }); - - assert.equal(array.data[0].attributes.condition, "healing"); -}); - test('normalize should allow for different levels of normalization', function(assert) { env.registry.register('serializer:application', DS.RESTSerializer.extend({ attrs: {