aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-04-30 10:27:41 -0700
committerMisko Hevery2010-04-30 10:27:41 -0700
commit549ff73a9b66e718383c79ccd7c28e4f9b25632d (patch)
tree17ff60f3a19a3d7b18d6c9a721e8f3f5745f635a
parentc7913a4b7a3f5ffb0ea6bb1e636ac9d4a0e75c32 (diff)
downloadangular.js-549ff73a9b66e718383c79ccd7c28e4f9b25632d.tar.bz2
clear cache on non-get
-rw-r--r--src/services.js1
-rw-r--r--test/servicesSpec.js8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/services.js b/src/services.js
index 36c89ccb..16dbcb35 100644
--- a/src/services.js
+++ b/src/services.js
@@ -262,6 +262,7 @@ angularService('$xhr.cache', function($xhr){
});
}
} else {
+ cache.data = {};
cache.delegate(method, url, post, callback);
}
}
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index f15d6ad7..112fc374 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -207,6 +207,7 @@ describe("service", function(){
describe('cache', function(){
var cache;
beforeEach(function(){ cache = scope.$xhr.cache; });
+
it('should cache requests', function(){
xhr.expectGET('/url').respond('first');
cache('GET', '/url', null, callback);
@@ -236,6 +237,13 @@ describe("service", function(){
xhr.flush();
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();
+ });
});
});