mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-16 10:43:10 +00:00
clear cache on non-get
This commit is contained in:
parent
c7913a4b7a
commit
549ff73a9b
2 changed files with 9 additions and 0 deletions
|
|
@ -262,6 +262,7 @@ angularService('$xhr.cache', function($xhr){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
cache.data = {};
|
||||||
cache.delegate(method, url, post, callback);
|
cache.delegate(method, url, post, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ describe("service", function(){
|
||||||
describe('cache', function(){
|
describe('cache', function(){
|
||||||
var cache;
|
var cache;
|
||||||
beforeEach(function(){ cache = scope.$xhr.cache; });
|
beforeEach(function(){ cache = scope.$xhr.cache; });
|
||||||
|
|
||||||
it('should cache requests', function(){
|
it('should cache requests', function(){
|
||||||
xhr.expectGET('/url').respond('first');
|
xhr.expectGET('/url').respond('first');
|
||||||
cache('GET', '/url', null, callback);
|
cache('GET', '/url', null, callback);
|
||||||
|
|
@ -236,6 +237,13 @@ describe("service", function(){
|
||||||
xhr.flush();
|
xhr.flush();
|
||||||
expect(log).toEqual('"123";"123";');
|
expect(log).toEqual('"123";"123";');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should clear cache on non GET', function(){
|
||||||
|
xhr.expectPOST('abc', {}).respond({});
|
||||||
|
cache.data.url = {value:123};
|
||||||
|
cache('POST', 'abc', {});
|
||||||
|
expect(cache.data.url).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue