Skip to content

Commit

Permalink
Merge pull request #26 from chrisiconolly/master
Browse files Browse the repository at this point in the history
Updates method interceptor to run last on http requests
  • Loading branch information
nabil-boag committed Dec 11, 2015
2 parents 08bd641 + aaa908b commit 12eaf77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/js/httpMethodInterceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ angular
})

.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push('httpMethodInterceptor');
$httpProvider.interceptors.unshift('httpMethodInterceptor');
}]);
21 changes: 20 additions & 1 deletion app/src/js/httpMethodInterceptor.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global describe, beforeEach, module, it, inject, jasmine, expect */
/* global describe, beforeEach, module, it, inject, jasmine, expect, spyOn */

describe('httpMethodInterceptor', function () {
var httpMethodInterceptor, httpMethodInterceptorProvider, mockQ,
Expand Down Expand Up @@ -206,4 +206,23 @@ describe('httpMethodInterceptor', function () {
expect(res).toBe(response);
});
});

describe('config sets $httpProvider interceptor', function () {
var $httpProvider;

beforeEach(function () {
module(function (_$httpProvider_) {
$httpProvider = _$httpProvider_;
spyOn($httpProvider.interceptors, 'unshift');
});
module('ng.httpLoader.httpMethodInterceptor');
inject();
});

it('should add to $httpProvider interceptors', function () {
expect($httpProvider.interceptors.unshift)
.toHaveBeenCalledWith('httpMethodInterceptor');
});
});
});

0 comments on commit 12eaf77

Please sign in to comment.