Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(ngResource): Remove request body from $delete
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bourey authored and jeffbcross committed Oct 4, 2013
1 parent 49e06ea commit 8336b3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ngResource/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions test/ngResource/resourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 8336b3a

Please sign in to comment.