aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorsimpulton2012-04-20 01:31:25 -0700
committerIgor Minar2012-04-20 12:32:33 -0700
commite61fd1b43a55496c11c63da7ca2fc05b88d44043 (patch)
tree007761363c98350ea42cda871b73dfb62d49b1a0 /test
parentce15a3e0491f7acafcdf0ff07f75d0c2c9819164 (diff)
downloadangular.js-e61fd1b43a55496c11c63da7ca2fc05b88d44043.tar.bz2
feat($resource): support HTTP PATCH method
Properly serialize data into request body instead of url. Closes #887
Diffstat (limited to 'test')
-rw-r--r--test/ngMock/angular-mocksSpec.js2
-rw-r--r--test/ngResource/resourceSpec.js17
2 files changed, 18 insertions, 1 deletions
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js
index 4b2666b7..22c91a4d 100644
--- a/test/ngMock/angular-mocksSpec.js
+++ b/test/ngMock/angular-mocksSpec.js
@@ -814,7 +814,7 @@ describe('ngMock', function() {
describe('expect/when shortcuts', function() {
angular.forEach(['expect', 'when'], function(prefix) {
- angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'JSONP'], function(method) {
+ angular.forEach(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'JSONP'], function(method) {
var shortcut = prefix + method;
it('should provide ' + shortcut + ' shortcut method', function() {
hb[shortcut]('/foo').respond('bar');
diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js
index 3235a6d0..2981732c 100644
--- a/test/ngResource/resourceSpec.js
+++ b/test/ngResource/resourceSpec.js
@@ -11,6 +11,9 @@ describe("resource", function() {
charge:{
method:'POST',
params:{verb:'!charge'}
+ },
+ patch: {
+ method: 'PATCH'
}
});
callback = jasmine.createSpy();
@@ -235,6 +238,20 @@ describe("resource", function() {
});
+ it("should patch a resource", function() {
+ $httpBackend.expectPATCH('/CreditCard/123', '{"name":"igor"}').
+ respond({id: 123, name: 'rama'});
+
+ var card = CreditCard.patch({id: 123}, {name: 'igor'}, callback);
+
+ expect(card).toEqualData({name: 'igor'});
+ expect(callback).not.toHaveBeenCalled();
+ $httpBackend.flush();
+ expect(callback).toHaveBeenCalled();
+ expect(card).toEqualData({id: 123, name: 'rama'});
+ });
+
+
it('should create on save', function() {
$httpBackend.expect('POST', '/CreditCard', '{"name":"misko"}').respond({id: 123}, {header1: 'a'});