mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-26 04:55:35 +08:00
feat($resource): support HTTP PATCH method
Properly serialize data into request body instead of url. Closes #887
This commit is contained in:
@@ -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'});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user