Skip to content

Commit

Permalink
Stable Version 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Jan 17, 2014
1 parent 996185b commit 43c45d8
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##### 0.5.0 - 16 January 2014

###### Backwards API changes
- #1 - Pluggable adapters
- #6 - Observable objects
- #7 - Model lifecycle hooks

###### Backwards compatible bug fixes
- #19 - Null pointer exception in several places where angular-data tries to use the $q service

##### Other
- #15 - Integration test coverage

##### 0.4.2 - 15 January 2014

###### Backwards compatible bug fixes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__Data store for Angular.js.__

__Current version:__ 0.4.2
__Current version:__ 0.5.0

Angular-data is in a pre-1.0.0 development stage; the API is fluctuating, not a lot of tests yet, etc.

Expand All @@ -12,7 +12,7 @@ Pending:
- Roadmap
- Website / documentation
- 100% tested (whatever _that_ means)
- See [issues](https://github.com/jmdobry/angular-data/issues?milestone=8&page=1&state=open) for what's in development
- See [issues](https://github.com/jmdobry/angular-data/issues?milestone=7&page=1&state=open) for what's in development

## Changelog
[CHANGELOG.md](https://github.com/jmdobry/angular-data/blob/master/CHANGELOG.md)
Expand Down
82 changes: 82 additions & 0 deletions test/integration/datastore/async_methods/findAll/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
describe('DS.findAll(resourceName, params[, options]): ', function () {
var errorPrefix = 'DS.findAll(resourceName, params[, options]): ';

it('should throw an error when method pre-conditions are not met', function (done) {
DS.findAll('does not exist', {}).then(function () {
fail('should have rejected');
}, function (err) {
assert.isTrue(err instanceof DS.errors.RuntimeError);
assert.equal(err.message, errorPrefix + 'does not exist is not a registered resource!');
});

angular.forEach(TYPES_EXCEPT_OBJECT, function (key) {
DS.findAll('post', key).then(function () {
fail('should have rejected');
}, function (err) {
assert.isTrue(err instanceof DS.errors.IllegalArgumentError);
assert.equal(err.message, errorPrefix + 'params: Must be an object!');
});
});

angular.forEach(TYPES_EXCEPT_OBJECT, function (key) {
if (key) {
DS.findAll('post', {}, key).then(function () {
fail('should have rejected');
}, function (err) {
assert.isTrue(err instanceof DS.errors.IllegalArgumentError);
assert.equal(err.message, errorPrefix + 'options: Must be an object!');
});
}
});

done();
});
it('should query the server for a collection', function (done) {
$httpBackend.expectGET('http://test.angular-cache.com/posts?').respond(200, [p1, p2, p3, p4]);

DS.findAll('post', {}).then(function (data) {
assert.deepEqual(data, [p1, p2, p3, p4]);
}, function (err) {
console.error(err.stack);
fail('Should not have rejected!');
});

assert.deepEqual(DS.filter('post', {}), [], 'The posts should not be in the store yet');

// Should have no effect because there is already a pending query
DS.findAll('post', {}).then(function (data) {
assert.deepEqual(data, [p1, p2, p3, p4]);
}, function (err) {
console.error(err.stack);
fail('Should not have rejected!');
});

$httpBackend.flush();

assert.deepEqual(DS.filter('post', {}), [p1, p2, p3, p4], 'The posts are now in the store');
assert.isNumber(DS.lastModified('post', 5));
assert.isNumber(DS.lastSaved('post', 5));

// Should not make a request because the request was already completed
DS.findAll('post', {}).then(function (data) {
assert.deepEqual(data, [p1, p2, p3, p4]);
}, function (err) {
console.error(err.stack);
fail('Should not have rejected!');
});

$httpBackend.expectGET('http://test.angular-cache.com/posts?').respond(200, [p1, p2, p3, p4]);

// Should make a request because bypassCache is set to true
DS.findAll('post', {}, { bypassCache: true }).then(function (data) {
assert.deepEqual(data, [p1, p2, p3, p4]);
}, function (err) {
console.error(err.stack);
fail('Should not have rejected!');
});

$httpBackend.flush();

done();
});
});

0 comments on commit 43c45d8

Please sign in to comment.