Skip to content

Commit d62127f

Browse files
committed
Added another test. #135
1 parent 92f9e92 commit d62127f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

karma.start.js

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function startInjector() {
149149
},
150150
belongsTo: {
151151
organization: {
152+
parent: true,
152153
localKey: 'organizationId',
153154
localField: 'organization'
154155
}

test/integration/datastore/async_methods/loadRelations.test.js

+28
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,34 @@ describe('DS.loadRelations(resourceName, instance(Id), relations[, options]): ',
131131
assert.equal(err.data, 'Not Found');
132132
});
133133

134+
$httpBackend.flush();
135+
});
136+
it('should handle multiple belongsTo levels', function () {
137+
var organization = DS.inject('organization', organization14);
138+
139+
var copy = angular.extend({}, user10);
140+
delete copy.organization;
141+
delete copy.comments;
142+
delete copy.profile;
143+
144+
$httpBackend.expectGET('http://test.angular-cache.com/organization/14/user').respond(200, [copy]);
145+
146+
DS.loadRelations('organization', organization, ['user']).then(function (organization) {
147+
assert.isTrue(organization === organization.users[0].organization);
148+
149+
$httpBackend.expectGET('http://test.angular-cache.com/user/10/comment').respond(200, [comment11, comment12]);
150+
151+
var user = DS.get('user', 10);
152+
153+
DS.loadRelations('user', user, ['comment']).then(function (user) {
154+
assert.isArray(user.comments);
155+
}, function () {
156+
fail('Should not have succeeded!');
157+
});
158+
}, function () {
159+
fail('Should not have succeeded!');
160+
});
161+
134162
$httpBackend.flush();
135163
});
136164
});

0 commit comments

Comments
 (0)