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

Commit

Permalink
fix(ngMock): keep withCredentials on passThrough
Browse files Browse the repository at this point in the history
When using passThrough() and specifying withCredentials on the $http
call, the option is now passed to the underlying $httpBackend.
  • Loading branch information
etiennebarrie authored and jeffbcross committed Aug 1, 2013
1 parent 3c0c716 commit 3079a6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
}

// TODO(vojta): change params to: method, url, data, headers, callback
function $httpBackend(method, url, data, callback, headers, timeout) {
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
var xhr = new MockXhr(),
expectation = expectations[0],
wasExpected = false;
Expand Down Expand Up @@ -1103,7 +1103,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
// if $browser specified, we do auto flush all requests
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
} else if (definition.passThrough) {
$delegate(method, url, data, callback, headers, timeout);
$delegate(method, url, data, callback, headers, timeout, withCredentials);
} else throw Error('No response defined !');
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,10 @@ describe('ngMockE2E', function() {
describe('passThrough()', function() {
it('should delegate requests to the real backend when passThrough is invoked', function() {
hb.when('GET', /\/passThrough\/.*/).passThrough();
hb('GET', '/passThrough/23', null, callback);
hb('GET', '/passThrough/23', null, callback, {}, null, true);

expect(realHttpBackend).toHaveBeenCalledOnceWith(
'GET', '/passThrough/23', null, callback, undefined, undefined);
'GET', '/passThrough/23', null, callback, {}, null, true);
});
});

Expand Down

0 comments on commit 3079a6f

Please sign in to comment.