From e51a0e13e82ffde9f0d752a5658de7d45e13af7e Mon Sep 17 00:00:00 2001 From: Lisa Backer Date: Sun, 26 Jun 2016 20:22:45 -0400 Subject: [PATCH] [CLEANUP beta] Remove feature flag for ds-serialize-ids-and-types (shipped in 2.6) #4416 --- FEATURES.md | 24 -------- addon/serializers/embedded-records-mixin.js | 9 +-- config/features.json | 1 - .../embedded-records-mixin-test.js | 57 +++++++++---------- 4 files changed, 29 insertions(+), 62 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index ba45a16dccd..1c6e0de793a 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -26,30 +26,6 @@ entry in `config/features.json`. Enables `pushPayload` to return the model(s) that are created or updated via the internal `store.push`. -- `ds-serialize-ids-and-types` [#3848](https://github.com/emberjs/data/pull/3848) - - Enables a new `ids-and-type` strategy (in addition to the already existing `ids` and `records`) for - serializing has many relationships using the `DS.EmbeddedRecordsMixin` that will include both - `id` and `type` of each model as an object. - - For instance, if a use has many pets, which is a polymorphic relationship, the generated payload would be: - - ```js - { - "user": { - "id": "1" - "name": "Bertin Osborne", - "pets": [ - { "id": "1", "type": "Cat" }, - { "id": "2", "type": "Parrot"} - ] - } - } - ``` - - This is particularly useful for polymorphic relationships not backed by STI when just including the id - of the records is not enough. - - `ds-extended-errors` [#3586](https://github.com/emberjs/data/pull/3586) [#4287](https://github.com/emberjs/data/pull/4287) Enables `extend` method on errors. It means you can extend from `DS.AdapterError`. diff --git a/addon/serializers/embedded-records-mixin.js b/addon/serializers/embedded-records-mixin.js index cfdd86a9430..f0da1a1f82e 100644 --- a/addon/serializers/embedded-records-mixin.js +++ b/addon/serializers/embedded-records-mixin.js @@ -1,6 +1,5 @@ import Ember from 'ember'; import { warn } from "ember-data/-private/debug"; -import isEnabled from 'ember-data/-private/features'; var get = Ember.get; var set = Ember.set; @@ -365,8 +364,6 @@ export default Ember.Mixin.create({ } ``` - Note that the `ids-and-types` strategy is still behind the `ds-serialize-ids-and-types` feature flag. - @method serializeHasMany @param {DS.Snapshot} snapshot @param {Object} json @@ -385,10 +382,8 @@ export default Ember.Mixin.create({ } else if (this.hasSerializeRecordsOption(attr)) { this._serializeEmbeddedHasMany(snapshot, json, relationship); } else { - if (isEnabled("ds-serialize-ids-and-types")) { - if (this.hasSerializeIdsAndTypesOption(attr)) { - this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship); - } + if (this.hasSerializeIdsAndTypesOption(attr)) { + this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship); } } }, diff --git a/config/features.json b/config/features.json index 79ca3c55c68..ab513781705 100644 --- a/config/features.json +++ b/config/features.json @@ -2,7 +2,6 @@ "ds-boolean-transform-allow-null": null, "ds-improved-ajax": null, "ds-pushpayload-return": null, - "ds-serialize-ids-and-types": true, "ds-extended-errors": null, "ds-links-in-record-array": null, "ds-overhaul-references": null, diff --git a/tests/integration/serializers/embedded-records-mixin-test.js b/tests/integration/serializers/embedded-records-mixin-test.js index 0d8f4351931..4b151636adb 100644 --- a/tests/integration/serializers/embedded-records-mixin-test.js +++ b/tests/integration/serializers/embedded-records-mixin-test.js @@ -5,7 +5,6 @@ import testInDebug from 'dummy/tests/helpers/test-in-debug'; import {module, test} from 'qunit'; import DS from 'ember-data'; -import isEnabled from 'ember-data/-private/features'; var get = Ember.get; var HomePlanet, SuperVillain, CommanderVillain, NormalMinion, EvilMinion, YellowMinion, RedMinion, SecretLab, SecretWeapon, BatCave, Comment, @@ -1074,38 +1073,36 @@ test("serialize with embedded objects (hasMany relationships, including related }); }); -if (isEnabled("ds-serialize-ids-and-types")) { - test("serialize has many relationship using the `ids-and-types` strategy", function(assert) { - run(function() { - yellowMinion = env.store.createRecord('yellow-minion', { id: 1, name: "Yellowy" }); - redMinion = env.store.createRecord('red-minion', { id: 1, name: "Reddy" }); - commanderVillain = env.store.createRecord('commander-villain', { id: 1, name: "Jeff", minions: [yellowMinion, redMinion] }); - }); +test("serialize has many relationship using the `ids-and-types` strategy", function(assert) { + run(function() { + yellowMinion = env.store.createRecord('yellow-minion', { id: 1, name: "Yellowy" }); + redMinion = env.store.createRecord('red-minion', { id: 1, name: "Reddy" }); + commanderVillain = env.store.createRecord('commander-villain', { id: 1, name: "Jeff", minions: [yellowMinion, redMinion] }); + }); - env.registry.register('serializer:commander-villain', DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { - attrs: { - minions: { serialize: 'ids-and-types' } - } - })); - var serializer, json; - run(function() { - serializer = env.container.lookup("serializer:commander-villain"); - var snapshot = commanderVillain._createSnapshot(); - json = serializer.serialize(snapshot); - }); + env.registry.register('serializer:commander-villain', DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { + attrs: { + minions: { serialize: 'ids-and-types' } + } + })); + var serializer, json; + run(function() { + serializer = env.container.lookup("serializer:commander-villain"); + var snapshot = commanderVillain._createSnapshot(); + json = serializer.serialize(snapshot); + }); - assert.deepEqual(json, { - name: 'Jeff', - minions: [{ - id: '1', - type: 'yellow-minion' - }, { - id: '1', - type: 'red-minion' - }] - }); + assert.deepEqual(json, { + name: 'Jeff', + minions: [{ + id: '1', + type: 'yellow-minion' + }, { + id: '1', + type: 'red-minion' + }] }); -} +}); test("normalizeResponse with embedded object (belongsTo relationship)", function(assert) { env.registry.register('serializer:super-villain', DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {