Skip to content

Commit 9e34ce2

Browse files
committed
Fixes #98.
Stable Version 0.10.1.
1 parent 5c49936 commit 9e34ce2

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##### 0.10.1 - xx July 2014
1+
##### 0.10.1 - 20 July 2014
22

33
##### Backwards compatible API changes
44
- #93 - Added `DS.createInstance(resourceName[, attrs][, options])`
@@ -9,6 +9,7 @@
99
- #91 - dist/angular-data(.min).js doesn't end with a semicolon (upgraded Browserify)
1010
- #94 - Resource object name/class inconsistency (added `useClass` option to `DS.defineResource`)
1111
- #95 - observe-js outdated (Upgraded observe-js.js an refactored to new API)
12+
- #98 - Missing id warning
1213

1314
##### 0.10.0 - 18 July 2014
1415

dist/angular-data.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5020,7 +5020,9 @@ function _inject(definition, resource, attrs) {
50205020
attrs[definition.idAttribute] = definition.computed[definition.idAttribute].apply(attrs, args);
50215021
}
50225022
if (!(definition.idAttribute in attrs)) {
5023-
throw new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
5023+
var error = new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
5024+
$log.error(error);
5025+
throw error;
50245026
} else {
50255027
try {
50265028
definition.beforeInject(definition.name, attrs);

dist/angular-data.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datastore/sync_methods/inject.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ function _inject(definition, resource, attrs) {
5656
attrs[definition.idAttribute] = definition.computed[definition.idAttribute].apply(attrs, args);
5757
}
5858
if (!(definition.idAttribute in attrs)) {
59-
throw new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
59+
var error = new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
60+
$log.error(error);
61+
throw error;
6062
} else {
6163
try {
6264
definition.beforeInject(definition.name, attrs);

test/integration/datastore/async_methods/findAll.test.js

+19
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
8484
assert.equal(lifecycle.serialize.callCount, 0, 'serialize should have been called');
8585
assert.equal(lifecycle.deserialize.callCount, 2, 'deserialize should have been called');
8686
});
87+
it('should fail when no "idAttribute" is present on an item in the response', function () {
88+
$httpBackend.expectGET(/http:\/\/test\.angular-cache\.com\/posts\??/).respond(200, [
89+
{ author: 'John', age: 30 },
90+
{ author: 'Sally', age: 31 }
91+
]);
92+
93+
DS.findAll('post', {}).then(function () {
94+
fail('Should not have succeeded!');
95+
}, function (err) {
96+
assert(err.message, 'DS.inject(resourceName, attrs[, options]): attrs: Must contain the property specified by `idAttribute`!');
97+
assert.deepEqual(DS.filter('post', {}), [], 'The posts should not be in the store');
98+
});
99+
100+
$httpBackend.flush();
101+
102+
assert($log.error.logs[0][0].message, 'DS.inject(resourceName, attrs[, options]): attrs: Must contain the property specified by `idAttribute`!');
103+
assert.equal(lifecycle.beforeInject.callCount, 0, 'beforeInject should not have been called');
104+
assert.equal(lifecycle.afterInject.callCount, 0, 'afterInject should not have been called');
105+
});
87106
it('should query the server for a collection but not store the data if cacheResponse is false', function () {
88107
$httpBackend.expectGET(/http:\/\/test\.angular-cache\.com\/posts\??/).respond(200, [p1, p2, p3, p4]);
89108

0 commit comments

Comments
 (0)