Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLEANUP beta] Remove feature flag for ds-serialize-ids-and-types (shipped in 2.6) #4416 #4451

Merged
merged 1 commit into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
9 changes: 2 additions & 7 deletions addon/serializers/embedded-records-mixin.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
},
Expand Down
1 change: 0 additions & 1 deletion config/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
57 changes: 27 additions & 30 deletions tests/integration/serializers/embedded-records-mixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, {
Expand Down