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

Commit

Permalink
fix($http): send GET requests by default
Browse files Browse the repository at this point in the history
Fixes #5985
Closes #6401
  • Loading branch information
pkozlowski-opensource authored and IgorMinar committed Feb 21, 2014
1 parent 2f45133 commit 267b217
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ function $HttpProvider() {
*/
function $http(requestConfig) {
var config = {
method: 'get',
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
};
Expand Down
14 changes: 14 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 267b217

Please sign in to comment.