Permalink
Browse files

Uses expiryUpdatedAt for remote expiry staleness instead of updatedAt

  • Loading branch information...
1 parent d31819f commit a1cf5c63296bd987000b22b55c0df2f4b9d37289 @hsume2 hsume2 committed Aug 31, 2012
Showing with 5 additions and 5 deletions.
  1. +3 −3 spec/javascripts/remoteExpirySpec.js
  2. +2 −2 src/remote_expiry.js
@@ -63,7 +63,7 @@ describe('remote expiry', function() {
remoteExpiryKey: "foo"
});
this.resource = Resource.create();
- this.date = new Date(1345511310 * 1000);
+ this.date = 1345511310;
spyOn(this.resource, 'expire');
spyOn(this.resource, 'fetch');
});
@@ -76,7 +76,7 @@ describe('remote expiry', function() {
});
it('should not expire resource when fresh', function() {
- this.resource.set('updatedAt', new Date((1345511310 + 200) * 1000));
+ this.resource.set('expiryUpdatedAt', 1345511310 + 200);
this.resource.updateExpiry({
updatedAt: this.date
});
@@ -111,7 +111,7 @@ describe('remote expiry', function() {
});
it('should not refetch resource when fresh', function() {
- this.resource.set('updatedAt', new Date((1345511310 + 200) * 1000));
+ this.resource.set('expiryUpdatedAt', 1345511310 + 200);
this.resource.updateExpiry({
updatedAt: this.date
});
@@ -49,7 +49,7 @@
var updatedAt = message && message.updatedAt;
if(!updatedAt) return;
if(this.stale(updatedAt)) {
- this.set('updatedAt', updatedAt);
+ this.set('expiryUpdatedAt', updatedAt);
if(this.get('remoteExpiryAutoFetch')) {
this.set('isExpired', true);
this.fetch();
@@ -60,7 +60,7 @@
},
stale: function(updatedAt) {
- return !this.get('updatedAt') || (+this.get('updatedAt') < +updatedAt);
+ return !this.get('expiryUpdatedAt') || (+this.get('expiryUpdatedAt') < +updatedAt);
}
});

0 comments on commit a1cf5c6

Please sign in to comment.