diff options
| author | Igor Minar | 2013-07-12 17:42:37 -0700 | 
|---|---|---|
| committer | Igor Minar | 2013-07-12 17:42:37 -0700 | 
| commit | 514dc0eb16a8fe3fa7c44094d743714f73754321 (patch) | |
| tree | 0429ae8755cab26ae276e7eab7d2c3b7ccfc1603 /test/ng/httpSpec.js | |
| parent | 77c715d7caedf9dd56b07b451dc47480cac5aaff (diff) | |
| download | angular.js-514dc0eb16a8fe3fa7c44094d743714f73754321.tar.bz2 | |
fix($http): allow interceptors to completely override headers
Closes #2770
Diffstat (limited to 'test/ng/httpSpec.js')
| -rw-r--r-- | test/ng/httpSpec.js | 23 | 
1 files changed, 22 insertions, 1 deletions
| diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index c21c6c23..cefc88e1 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -284,6 +284,27 @@ describe('$http', function() {          });        }); + +      it('should allow replacement of the headers object', function() { +        module(function($httpProvider) { +          $httpProvider.interceptors.push(function() { +            return { +              request: function(config) { +                config.headers = {foo: 'intercepted'}; +                return config; +              } +            }; +          }); +        }); +        inject(function($http, $httpBackend, $rootScope) { +          $httpBackend.expect('GET', '/url', null, function (headers) { +            return angular.equals(headers, {foo: 'intercepted'}); +          }).respond(''); +          $http.get('/url'); +          $rootScope.$apply(); +        }); +      }); +        it('should reject the http promise if an interceptor fails', function() {          var reason = new Error('interceptor failed');          module(function($httpProvider) { @@ -752,7 +773,7 @@ describe('$http', function() {          $httpBackend.expect('POST', '/url2', undefined, function(headers) {            return !headers.hasOwnProperty('content-type');          }).respond(''); -         +          $http({url: '/url', method: 'POST'});          $http({url: '/url2', method: 'POST', headers: {'content-type': 'Rewritten'}});          $httpBackend.flush(); | 
