Skip to content

Commit

Permalink
Fixes #98.
Browse files Browse the repository at this point in the history
Stable Version 0.10.1.
  • Loading branch information
jmdobry committed Jul 20, 2014
1 parent 5c49936 commit 9e34ce2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##### 0.10.1 - xx July 2014
##### 0.10.1 - 20 July 2014

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

##### 0.10.0 - 18 July 2014

Expand Down
4 changes: 3 additions & 1 deletion dist/angular-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5020,7 +5020,9 @@ function _inject(definition, resource, attrs) {
attrs[definition.idAttribute] = definition.computed[definition.idAttribute].apply(attrs, args);
}
if (!(definition.idAttribute in attrs)) {
throw new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
var error = new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
$log.error(error);
throw error;
} else {
try {
definition.beforeInject(definition.name, attrs);
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-data.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/datastore/sync_methods/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ function _inject(definition, resource, attrs) {
attrs[definition.idAttribute] = definition.computed[definition.idAttribute].apply(attrs, args);
}
if (!(definition.idAttribute in attrs)) {
throw new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
var error = new _this.errors.R(errorPrefix + 'attrs: Must contain the property specified by `idAttribute`!');
$log.error(error);
throw error;
} else {
try {
definition.beforeInject(definition.name, attrs);
Expand Down
19 changes: 19 additions & 0 deletions test/integration/datastore/async_methods/findAll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
assert.equal(lifecycle.serialize.callCount, 0, 'serialize should have been called');
assert.equal(lifecycle.deserialize.callCount, 2, 'deserialize should have been called');
});
it('should fail when no "idAttribute" is present on an item in the response', function () {
$httpBackend.expectGET(/http:\/\/test\.angular-cache\.com\/posts\??/).respond(200, [
{ author: 'John', age: 30 },
{ author: 'Sally', age: 31 }
]);

DS.findAll('post', {}).then(function () {
fail('Should not have succeeded!');
}, function (err) {
assert(err.message, 'DS.inject(resourceName, attrs[, options]): attrs: Must contain the property specified by `idAttribute`!');
assert.deepEqual(DS.filter('post', {}), [], 'The posts should not be in the store');
});

$httpBackend.flush();

assert($log.error.logs[0][0].message, 'DS.inject(resourceName, attrs[, options]): attrs: Must contain the property specified by `idAttribute`!');
assert.equal(lifecycle.beforeInject.callCount, 0, 'beforeInject should not have been called');
assert.equal(lifecycle.afterInject.callCount, 0, 'afterInject should not have been called');
});
it('should query the server for a collection but not store the data if cacheResponse is false', function () {
$httpBackend.expectGET(/http:\/\/test\.angular-cache\.com\/posts\??/).respond(200, [p1, p2, p3, p4]);

Expand Down

0 comments on commit 9e34ce2

Please sign in to comment.