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

Commit 46691c2

Browse files
committed
fix($http): remove support for PATCH + better whenXXX, expectXXX api
- there are too many unknowns about PATCH, so I'm dropping its support until we know that this is actually useful - expectGET, expectHEAD and expectJSON (and the same for whenXXX) should not require response data to be specified
1 parent e7a23e4 commit 46691c2

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

src/angular-mocks.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,17 @@ function createHttpBackendMock($delegate, $defer) {
748748

749749

750750
function createShortMethods(prefix) {
751-
angular.forEach(['GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'JSONP'], function(method) {
752-
$httpBackend[prefix + method] = function(url, data, headers) {
753-
return $httpBackend[prefix](method, url, data, headers)
751+
angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) {
752+
$httpBackend[prefix + method] = function(url, headers) {
753+
return $httpBackend[prefix](method, url, undefined, headers)
754754
}
755755
});
756+
757+
angular.forEach(['PUT', 'POST'], function(method) {
758+
$httpBackend[prefix + method] = function(url, data, headers) {
759+
return $httpBackend[prefix](method, url, data, headers)
760+
}
761+
});
756762
}
757763
};
758764

src/service/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function $HttpProvider() {
287287
* @param {Object=} config Optional configuration object
288288
* @returns {XhrFuture} Future object
289289
*/
290-
createShortMethods('get', 'delete', 'head', 'patch', 'jsonp');
290+
createShortMethods('get', 'delete', 'head', 'jsonp');
291291

292292
/**
293293
* @ngdoc method

test/angular-mocksSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,9 @@ describe('ngMock', function() {
819819
});
820820

821821

822-
describe('expect/when shorcuts', function() {
822+
describe('expect/when shortcuts', function() {
823823
angular.forEach(['expect', 'when'], function(prefix) {
824-
angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'JSONP'], function(method) {
824+
angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'JSONP'], function(method) {
825825
var shortcut = prefix + method;
826826
it('should provide ' + shortcut + ' shortcut method', function() {
827827
hb[shortcut]('/foo').respond('bar');

test/service/httpSpec.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,18 +479,6 @@ describe('$http', function() {
479479
});
480480

481481

482-
it('should have patch()', function() {
483-
$httpBackend.expect('PATCH', '/url').respond('');
484-
$http.patch('/url');
485-
});
486-
487-
488-
it('patch() should allow config param', function() {
489-
$httpBackend.expect('PATCH', '/url', undefined, checkHeader('Custom', 'Header')).respond('');
490-
$http.patch('/url', {headers: {'Custom': 'Header'}});
491-
});
492-
493-
494482
it('should have post()', function() {
495483
$httpBackend.expect('POST', '/url', 'some-data').respond('');
496484
$http.post('/url', 'some-data');

0 commit comments

Comments
 (0)