mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-16 18:51:06 +00:00
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:
parent
49e06eace5
commit
8336b3a286
2 changed files with 11 additions and 1 deletions
|
|
@ -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);
|
route.setUrlParams(httpConfig, extend({}, extractParams(data, action.params || {}), params), action.url);
|
||||||
|
|
||||||
var promise = $http(httpConfig).then(function(response) {
|
var promise = $http(httpConfig).then(function(response) {
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
it("should build resource", function() {
|
||||||
expect(typeof CreditCard).toBe('function');
|
expect(typeof CreditCard).toBe('function');
|
||||||
expect(typeof CreditCard.get).toBe('function');
|
expect(typeof CreditCard.get).toBe('function');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue