From e47a35ee3e7e5eccd66a221637b0c8d5a3477182 Mon Sep 17 00:00:00 2001 From: Dag-Inge Aas Date: Fri, 31 Jan 2014 12:59:55 +0100 Subject: [PATCH] fix($http): add support for PATCH short method Commit 46691c2721735c27426b721d780e8816d502b9f2 removed the short method for PATCH from $http because there were too many unknows. However, #5823 schedules PATCH to be re-added for the 1.3.x milestone. This change adds the short method for PATCH back to the $http library, including tests. Closes #5823 --- src/ng/http.js | 2 +- test/ng/httpSpec.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ng/http.js b/src/ng/http.js index 57dc71721d10..5ddee858b26b 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -847,7 +847,7 @@ function $HttpProvider() { * @param {Object=} config Optional configuration object * @returns {HttpPromise} Future object */ - createShortMethods('get', 'delete', 'head', 'jsonp'); + createShortMethods('get', 'delete', 'head', 'jsonp', 'patch'); /** * @ngdoc method diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index a0417d9ad99c..0289721d3137 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -873,6 +873,15 @@ describe('$http', function() { $http.head('/url', {headers: {'Custom': 'Header'}}); }); + it('should have patch()', function() { + $httpBackend.expect('PATCH', '/url').respond(''); + $http.patch('/url'); + }); + + it('patch() should allow config param', function() { + $httpBackend.expect('PATCH', '/url', undefined, checkHeader('Custom', 'Header')).respond(''); + $http.patch('/url', {headers: {'Custom': 'Header'}}); + }); it('should have post()', function() { $httpBackend.expect('POST', '/url', 'some-data').respond('');