diff options
| author | Pawel Kozlowski | 2014-02-21 22:24:27 +0100 | 
|---|---|---|
| committer | Igor Minar | 2014-02-21 14:42:03 -0800 | 
| commit | 267b217376ed466e9f260ecfdfa15a8227c103ff (patch) | |
| tree | 15eeb7ec88c1afb503369474a72cb78813af5fa0 | |
| parent | 2f4513339337bb8aa6c9dfe1191d169b4fc57999 (diff) | |
| download | angular.js-267b217376ed466e9f260ecfdfa15a8227c103ff.tar.bz2 | |
fix($http): send GET requests by default
Fixes #5985
Closes #6401
| -rw-r--r-- | src/ng/http.js | 1 | ||||
| -rw-r--r-- | test/ng/httpSpec.js | 14 | 
2 files changed, 15 insertions, 0 deletions
| diff --git a/src/ng/http.js b/src/ng/http.js index a8b1d9df..defe43dc 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -664,6 +664,7 @@ function $HttpProvider() {       */      function $http(requestConfig) {        var config = { +        method: 'get',          transformRequest: defaults.transformRequest,          transformResponse: defaults.transformResponse        }; diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index a0417d9a..d446a80c 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -405,6 +405,10 @@ describe('$http', function() {        $http = $h;      }])); +    it('should send GET requests if no method specified', inject(function($httpBackend, $http) { +      $httpBackend.expect('GET', '/url').respond(''); +      $http({url: '/url'}); +    }));      it('should do basic request', inject(function($httpBackend, $http) {        $httpBackend.expect('GET', '/url').respond(''); @@ -1120,6 +1124,16 @@ describe('$http', function() {          expect(callback.mostRecentCall.args[0]).toBe('content');        })); +      it('should cache request when cache is provided and no method specified', function () { +        doFirstCacheRequest(); + +        $http({url: '/url', cache: cache}).success(callback); +        $rootScope.$digest(); + +        expect(callback).toHaveBeenCalledOnce(); +        expect(callback.mostRecentCall.args[0]).toBe('content'); +      }); +        it('should not cache when cache is not provided', function() {          doFirstCacheRequest(); | 
