Skip to content

Commit 4ffa6d4

Browse files
committed
Closes #120.
1 parent 64d9eac commit 4ffa6d4

File tree

10 files changed

+59
-12
lines changed

10 files changed

+59
-12
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 0.10.6 - xx August 2014
2+
3+
###### Backwards compatible API changes
4+
- #120 - When using DSCacheFactory, allow onExpire to be specified
5+
16
##### 0.10.5 - 14 August 2014
27

38
###### Backwards compatible API changes

Gruntfile.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ module.exports = function (grunt) {
117117
]
118118
}
119119
},
120+
DSCacheFactory: {
121+
browsers: ['Firefox', 'PhantomJS'],
122+
options: {
123+
files: [
124+
'bower_components/angular/angular.js',
125+
'bower_components/angular-mocks/angular-mocks.js',
126+
'bower_components/angular-cache/dist/angular-cache.js',
127+
'dist/angular-data.js',
128+
'karma.start.js',
129+
'test/integration/datastore/DSCacheFactory.test.js'
130+
]
131+
}
132+
},
120133
ci: {
121134
browsers: ['Firefox', 'PhantomJS'],
122135
exclude: [
@@ -356,7 +369,7 @@ module.exports = function (grunt) {
356369
grunt.file.write('dist/angular-data.js', file);
357370
});
358371

359-
grunt.registerTask('test', ['build', 'karma:ci', 'karma:cacheFactory', 'karma:min']);
372+
grunt.registerTask('test', ['build', 'karma:ci', 'karma:cacheFactory', 'karma:DSCacheFactory', 'karma:min']);
360373
grunt.registerTask('doc', ['clean:doc', 'docular', 'concat', 'copy', 'clean:afterDoc', 'uglify:scripts']);
361374
grunt.registerTask('build', [
362375
'clean',

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
__Data store for Angular.js.__
44

5-
__Latest Release:__ [0.10.5](http://angular-data.pseudobry.com/)
6-
__master:__ [0.10.5](http://angular-data-next.pseudobry.com/)
5+
__Latest Release:__ [0.10.6](http://angular-data.pseudobry.com/)
6+
__master:__ [0.10.6](http://angular-data-next.pseudobry.com/)
77

88
Angular-data is approaching 1.0.0 Beta. The API is stabilizing and angular-data is well tested.
99

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Jason Dobry",
33
"name": "angular-data",
44
"description": "Data store for Angular.js.",
5-
"version": "0.10.5",
5+
"version": "0.10.6",
66
"homepage": "http://angular-data.pseudobry.com/",
77
"repository": {
88
"type": "git",

dist/angular-data.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @author Jason Dobry <[email protected]>
33
* @file angular-data.js
4-
* @version 0.10.5 - Homepage <http://angular-data.pseudobry.com/>
4+
* @version 0.10.6 - Homepage <http://angular-data.pseudobry.com/>
55
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
66
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
77
*
@@ -4542,7 +4542,10 @@ function defineResource(definition) {
45424542
cacheFlushInterval: def.cacheFlushInterval || null,
45434543
deleteOnExpire: def.deleteOnExpire || 'none',
45444544
onExpire: function (id) {
4545-
DS.eject(def.name, id);
4545+
var item = DS.eject(def.name, id);
4546+
if (DS.utils.isFunction(def.onExpire)) {
4547+
def.onExpire(id, item);
4548+
}
45464549
},
45474550
capacity: Number.MAX_VALUE,
45484551
storageMode: 'memory',

dist/angular-data.min.js

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

guide/nav.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<i class="icon-wrench icon-white"></i> API <b class="caret"></b>
7373
</a>
7474
<ul class="dropdown-menu">
75-
<li class="nav-header">Angular-data - 0.10.5</li>
75+
<li class="nav-header">Angular-data - 0.10.6</li>
7676
<li>
7777
<a href="/documentation/api/angular-data/angular-data">Overview</a>
7878
</li>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-data",
33
"description": "Data store for Angular.js.",
4-
"version": "0.10.5",
4+
"version": "0.10.6",
55
"homepage": "http://angular-data.pseudobry.com",
66
"repository": {
77
"type": "git",

src/datastore/sync_methods/defineResource.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ function defineResource(definition) {
142142
cacheFlushInterval: def.cacheFlushInterval || null,
143143
deleteOnExpire: def.deleteOnExpire || 'none',
144144
onExpire: function (id) {
145-
DS.eject(def.name, id);
145+
var item = DS.eject(def.name, id);
146+
if (DS.utils.isFunction(def.onExpire)) {
147+
def.onExpire(id, item);
148+
}
146149
},
147150
capacity: Number.MAX_VALUE,
148151
storageMode: 'memory',

test/integration/datastore/DSCacheFactory.test.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ describe('DSCacheFactory integration', function () {
5555
endpoint: '/comments',
5656
deleteOnExpire: 'aggressive',
5757
recycleFreq: 10,
58-
maxAge: 20
58+
maxAge: 20,
59+
onExpire: sinon.spy()
5960
});
6061

6162
$httpBackend.expectGET('http://test.angular-cache.com/comments/5').respond(200, {
@@ -85,11 +86,33 @@ describe('DSCacheFactory integration', function () {
8586
setTimeout(function () {
8687
assert.isUndefined(DS.get('Comment', 5));
8788

89+
assert.equal(DS.definitions.Comment.onExpire.callCount, 1, 'onExpire should have been called once');
90+
assert.isTrue(DS.definitions.Comment.onExpire.calledWithExactly('5', {
91+
id: 5,
92+
text: 'test'
93+
}), 'onExpire should have been called with the right arguments');
8894
assert.equal(lifecycle.beforeInject.callCount, 1, 'beforeInject should have been called');
8995
assert.equal(lifecycle.afterInject.callCount, 1, 'afterInject should have been called');
9096
assert.equal(lifecycle.serialize.callCount, 0, 'serialize should have been called');
9197
assert.equal(lifecycle.deserialize.callCount, 1, 'deserialize should have been called');
9298

99+
$httpBackend.expectGET('http://test.angular-cache.com/comments/5').respond(200, {
100+
id: 5,
101+
text: 'test'
102+
});
103+
104+
DS.find('Comment', 5).then(function (comment) {
105+
assert.deepEqual(comment, {
106+
id: 5,
107+
text: 'test'
108+
});
109+
}, function (err) {
110+
console.error(err.stack);
111+
fail('Should not have rejected!');
112+
});
113+
114+
$httpBackend.flush();
115+
93116
done();
94117
}, 100);
95118
});

0 commit comments

Comments
 (0)