Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Sideloading should respect namingConvention #384

Closed
wants to merge 1 commit into from

2 participants

Bradley Priest Peter Wagenet
Bradley Priest
Collaborator

No description provided.

Bradley Priest
Collaborator

I'm pretty sure sideloading doesn't respect user-specified keys either

Peter Wagenet
Owner

@bradleypriest Is this still an issue on master? If so, can you rebase?

Bradley Priest
Collaborator

@wagenet It's still an issue, I've pushed a failing testcase for master, however with the RI stuff now the naming convention is a separate object and I can't work out how to actually fix it anymore. If anyone else wants to add a second set of eyes, I think the issue is needing to transform the name attribute here. https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/associations/ext.js#L72

Peter Wagenet
Owner

@bradleypriest, I suspect this is fixed now. If not, let us know.

Peter Wagenet wagenet closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 18, 2012
  1. Bradley Priest
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 1 deletion.
  1. +27 −1 packages/ember-data/tests/unit/rest_adapter_test.js
28 packages/ember-data/tests/unit/rest_adapter_test.js
View
@@ -4,6 +4,7 @@ var adapter, store, ajaxUrl, ajaxType, ajaxHash;
var Person, person, people;
var Role, role, roles;
var Group, group;
+var SharedInterest;
module("the REST adapter", {
setup: function() {
@@ -43,9 +44,18 @@ module("the REST adapter", {
return "App.Person";
};
+ SharedInterest = DS.Model.extend({
+ name: DS.attr('string')
+ });
+
+ SharedInterest.toString = function() {
+ return "App.SharedInterest";
+ };
+
Group = DS.Model.extend({
name: DS.attr('string'),
- people: DS.hasMany(Person)
+ people: DS.hasMany(Person),
+ sharedInterests: DS.hasMany(SharedInterest)
});
Group.toString = function() {
@@ -447,6 +457,22 @@ test("additional data can be sideloaded in a GET", function() {
equal(get(get(store.find(Group, 1), 'people').objectAt(0), 'name'), "Yehuda Katz", "the items are in the association");
});
+test("sideloading respects naming convention", function() {
+ group = store.find(Group, 1);
+
+ ajaxHash.success({
+ group: {
+ id: 1, name: "Group 1", shared_interests: [ 1 ]
+ },
+ shared_interests: [{
+ id: 1, name: "Balloons"
+ }]
+ });
+
+ equal(get(store.find(SharedInterest, 1), 'name'), "Balloons", "the items are sideloaded");
+ equal(get(get(store.find(Group, 1), 'sharedInterests').objectAt(0), 'name'), "Balloons", "the items are in the association");
+});
+
test("finding many people by a list of IDs", function() {
store.load(Group, { id: 1, people: [ 1, 2, 3 ] });
Something went wrong with that request. Please try again.