Skip to content

Commit

Permalink
Merge pull request #3430 from wecc/remove-old-serializer-api
Browse files Browse the repository at this point in the history
[CLEANUP beta] Remove old Serializer API
  • Loading branch information
wecc committed Jun 24, 2015
2 parents 9022250 + b0a8eaf commit b57ba30
Show file tree
Hide file tree
Showing 29 changed files with 1,333 additions and 3,902 deletions.
2 changes: 1 addition & 1 deletion packages/activemodel-adapter/lib/setup-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default function setupActiveModelAdapter(registry, application) {
{ deprecated: 'adapter:_ams', valid: 'adapter:-active-model' }
]);

registry.register('serializer:-active-model', ActiveModelSerializer.extend({ isNewSerializerAPI: true }));
registry.register('serializer:-active-model', ActiveModelSerializer);
registry.register('adapter:-active-model', ActiveModelAdapter);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,42 +78,72 @@ test("serialize polymorphic when type key is not camelized", function() {

test("extractPolymorphic hasMany", function() {
var json_hash = {
mediocre_villain: { id: 1, name: "Dr Horrible", evil_minions: [{ type: "EvilMinions::YellowMinion", id: 12 }] },
evil_minions: [{ id: 12, name: "Alex", doomsday_device_ids: [1] }]
mediocre_villain: { id: 1, name: "Dr Horrible", evil_minion_ids: [{ type: "EvilMinions::YellowMinion", id: 12 }] },
"evil-minions/yellow-minion": [{ id: 12, name: "Alex", doomsday_device_ids: [1] }]
};
var json;

run(function() {
json = env.amsSerializer.extractSingle(env.store, MediocreVillain, json_hash);
json = env.amsSerializer.normalizeResponse(env.store, MediocreVillain, json_hash, '1', 'findRecord');
});

deepEqual(json, {
"id": 1,
"name": "Dr Horrible",
"evilMinions": [{
type: "evil-minions/yellow-minion",
id: 12
"data": {
"id": "1",
"type": "mediocre-villain",
"attributes": {
"name": "Dr Horrible"
},
"relationships": {
"evilMinions": {
"data": [
{ "id": "12", "type": "evil-minions/yellow-minion" }
]
}
}
},
"included": [{
"id": "12",
"type": "evil-minions/yellow-minion",
"attributes": {
"name": "Alex"
},
"relationships": {}
}]
});
});

test("extractPolymorphic", function() {
test("extractPolymorphic belongsTo", function() {
var json_hash = {
doomsday_device: { id: 1, name: "DeathRay", evil_minion: { type: "EvilMinions::YellowMinion", id: 12 } },
evil_minions: [{ id: 12, name: "Alex", doomsday_device_ids: [1] }]
doomsday_device: { id: 1, name: "DeathRay", evil_minion_id: { type: "EvilMinions::YellowMinion", id: 12 } },
"evil-minions/yellow-minion": [{ id: 12, name: "Alex", doomsday_device_ids: [1] }]
};
var json;

run(function() {
json = env.amsSerializer.extractSingle(env.store, DoomsdayDevice, json_hash);
json = env.amsSerializer.normalizeResponse(env.store, DoomsdayDevice, json_hash, '1', 'findRecord');
});

deepEqual(json, {
"id": 1,
"name": "DeathRay",
"evilMinion": {
type: "evil-minions/yellow-minion",
id: 12
}
"data": {
"id": "1",
"type": "doomsday-device",
"attributes": {
"name": "DeathRay"
},
"relationships": {
"evilMinion": {
"data": { "id": "12", "type": "evil-minions/yellow-minion" }
}
}
},
"included": [{
"id": "12",
"type": "evil-minions/yellow-minion",
"attributes": {
"name": "Alex"
},
"relationships": {}
}]
});
});
Loading

0 comments on commit b57ba30

Please sign in to comment.