diff options
| author | Igor Minar | 2012-01-10 10:17:05 -0800 |
|---|---|---|
| committer | Igor Minar | 2012-01-13 13:53:07 -0800 |
| commit | 46691c2721735c27426b721d780e8816d502b9f2 (patch) | |
| tree | 53ff9471d7fa799bf6186ea21bf969a8d9b7b359 | |
| parent | e7a23e4b6585d497112935a7d00cb6906d8c8417 (diff) | |
| download | angular.js-46691c2721735c27426b721d780e8816d502b9f2.tar.bz2 | |
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
| -rw-r--r-- | src/angular-mocks.js | 12 | ||||
| -rw-r--r-- | src/service/http.js | 2 | ||||
| -rw-r--r-- | test/angular-mocksSpec.js | 4 | ||||
| -rw-r--r-- | test/service/httpSpec.js | 12 |
4 files changed, 12 insertions, 18 deletions
diff --git a/src/angular-mocks.js b/src/angular-mocks.js index 5b3e6fc3..0d284884 100644 --- a/src/angular-mocks.js +++ b/src/angular-mocks.js @@ -748,11 +748,17 @@ function createHttpBackendMock($delegate, $defer) { function createShortMethods(prefix) { - angular.forEach(['GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'JSONP'], function(method) { - $httpBackend[prefix + method] = function(url, data, headers) { - return $httpBackend[prefix](method, url, data, headers) + angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) { + $httpBackend[prefix + method] = function(url, headers) { + return $httpBackend[prefix](method, url, undefined, headers) } }); + + angular.forEach(['PUT', 'POST'], function(method) { + $httpBackend[prefix + method] = function(url, data, headers) { + return $httpBackend[prefix](method, url, data, headers) + } + }); } }; diff --git a/src/service/http.js b/src/service/http.js index fec4fc8d..e9c49ec2 100644 --- a/src/service/http.js +++ b/src/service/http.js @@ -287,7 +287,7 @@ function $HttpProvider() { * @param {Object=} config Optional configuration object * @returns {XhrFuture} Future object */ - createShortMethods('get', 'delete', 'head', 'patch', 'jsonp'); + createShortMethods('get', 'delete', 'head', 'jsonp'); /** * @ngdoc method diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js index 153c2e33..073d6cd1 100644 --- a/test/angular-mocksSpec.js +++ b/test/angular-mocksSpec.js @@ -819,9 +819,9 @@ describe('ngMock', function() { }); - describe('expect/when shorcuts', function() { + describe('expect/when shortcuts', function() { angular.forEach(['expect', 'when'], function(prefix) { - angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'JSONP'], function(method) { + angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'JSONP'], function(method) { var shortcut = prefix + method; it('should provide ' + shortcut + ' shortcut method', function() { hb[shortcut]('/foo').respond('bar'); diff --git a/test/service/httpSpec.js b/test/service/httpSpec.js index c6adee9e..d827e941 100644 --- a/test/service/httpSpec.js +++ b/test/service/httpSpec.js @@ -479,18 +479,6 @@ describe('$http', function() { }); - 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(''); $http.post('/url', 'some-data'); |
