Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Demonstrate unwanted record sharing.

By adding a pingbacks relationship and not modifying it in any test, we
should end up with an empty array in all serialized Posts, i.e.

    {
        "post": {
            "comments": [
                {
                    "title": "Wouldn't a more lightweight...",
                    "user": null
                },
                {
                    "title": "This does not seem to reflect...",
                    "user": null
                }
            ],
            "pingbacks": [],
            "title": "A New MVC Framework in Under 100 Lines of Code"
        }
    }

However, what we get is

    {
        "post": {
            "comments": [
                {
                    "title": "Wouldn't a more lightweight...",
                    "user": null
                },
                {
                    "title": "This does not seem to reflect...",
                    "user": null
                }
            ],
            "pingbacks": [
                {
                    "title": "Wouldn't a more lightweight...",
                    "user": null
                },
                {
                    "title": "This does not seem to reflect...",
                    "user": null
                }
            ],
            "title": "A New MVC Framework in Under 100 Lines of Code"
        }
    }
  • Loading branch information...
commit 54927ae391cfc1ac857d7ddbdc59da59090de094 1 parent a72ed12
@yipdw yipdw authored
View
19 packages/ember-data/tests/integration/embedded/embedded_without_ids_test.js
@@ -1,5 +1,5 @@
var store, Adapter, adapter;
-var Post, Comment, User;
+var Post, Comment, User, Pingback;
var attr = DS.attr;
module("Embedded Relationships Without IDs", {
@@ -15,9 +15,13 @@ module("Embedded Relationships Without IDs", {
user: DS.belongsTo(User)
});
+ Pingback = App.Pingback = DS.Model.extend({
+ });
+
Post = App.Post = DS.Model.extend({
title: attr('string'),
- comments: DS.hasMany(Comment)
+ comments: DS.hasMany(Comment),
+ pingbacks: DS.hasMany(Pingback)
});
Adapter = DS.RESTAdapter.extend();
@@ -27,7 +31,8 @@ module("Embedded Relationships Without IDs", {
});
Adapter.map(Post, {
- comments: { embedded: 'always' }
+ comments: { embedded: 'always' },
+ pingbacks: { embedded: 'always' }
});
adapter = Adapter.create();
@@ -167,7 +172,9 @@ asyncTest("Embedded hasMany relationships can be saved when embedded: always is
{
title: "This does not seem to reflect the Unix philosophy haha",
user: null
- }]
+ }],
+
+ pingbacks: []
}
});
@@ -265,7 +272,9 @@ asyncTest("Embedded records that contain embedded records can be saved", functio
user: {
name: "microuser"
}
- }]
+ }],
+
+ pingbacks: []
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.