feat($resource): support HTTP PATCH method

Properly serialize data into request body instead of url.

Closes #887
This commit is contained in:
simpulton
2012-04-20 01:31:25 -07:00
committed by Igor Minar
parent ce15a3e049
commit e61fd1b43a
4 changed files with 50 additions and 5 deletions

View File

@@ -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'});