fix(ngResource): Remove request body from $delete

Prevent the  obj.$delete instance method from sending the resource as the request body.  This commit uses the existing hasBody boolean to only set httpConfig.data for methods which should have a request body.

Closes #4280
This commit is contained in:
Jen Bourey 2013-10-04 12:02:18 -07:00 committed by Jeff Cross
parent 49e06eace5
commit 8336b3a286
2 changed files with 11 additions and 1 deletions

View file

@ -466,7 +466,7 @@ angular.module('ngResource', ['ng']).
}
});
httpConfig.data = data;
if (hasBody) httpConfig.data = data;
route.setUrlParams(httpConfig, extend({}, extractParams(data, action.params || {}), params), action.url);
var promise = $http(httpConfig).then(function(response) {

View file

@ -32,6 +32,16 @@ describe("resource", function() {
});
it('should not include a request body when calling $delete', function() {
$httpBackend.expect('DELETE', '/fooresource', null).respond({});
var Resource = $resource('/fooresource');
var resource = new Resource({ foo: 'bar' });
resource.$delete();
$httpBackend.flush();
});
it("should build resource", function() {
expect(typeof CreditCard).toBe('function');
expect(typeof CreditCard.get).toBe('function');