mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-28 15:28:15 +00:00
fix(ngMock): keep withCredentials on passThrough
When using passThrough() and specifying withCredentials on the $http call, the option is now passed to the underlying $httpBackend.
This commit is contained in:
parent
3c0c7165e2
commit
3079a6f4e0
2 changed files with 4 additions and 4 deletions
4
src/ngMock/angular-mocks.js
vendored
4
src/ngMock/angular-mocks.js
vendored
|
|
@ -1045,7 +1045,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(vojta): change params to: method, url, data, headers, callback
|
// 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(),
|
var xhr = new MockXhr(),
|
||||||
expectation = expectations[0],
|
expectation = expectations[0],
|
||||||
wasExpected = false;
|
wasExpected = false;
|
||||||
|
|
@ -1103,7 +1103,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||||
// if $browser specified, we do auto flush all requests
|
// if $browser specified, we do auto flush all requests
|
||||||
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
|
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
|
||||||
} else if (definition.passThrough) {
|
} 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 !');
|
} else throw Error('No response defined !');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
test/ngMock/angular-mocksSpec.js
vendored
4
test/ngMock/angular-mocksSpec.js
vendored
|
|
@ -1088,10 +1088,10 @@ describe('ngMockE2E', function() {
|
||||||
describe('passThrough()', function() {
|
describe('passThrough()', function() {
|
||||||
it('should delegate requests to the real backend when passThrough is invoked', function() {
|
it('should delegate requests to the real backend when passThrough is invoked', function() {
|
||||||
hb.when('GET', /\/passThrough\/.*/).passThrough();
|
hb.when('GET', /\/passThrough\/.*/).passThrough();
|
||||||
hb('GET', '/passThrough/23', null, callback);
|
hb('GET', '/passThrough/23', null, callback, {}, null, true);
|
||||||
|
|
||||||
expect(realHttpBackend).toHaveBeenCalledOnceWith(
|
expect(realHttpBackend).toHaveBeenCalledOnceWith(
|
||||||
'GET', '/passThrough/23', null, callback, undefined, undefined);
|
'GET', '/passThrough/23', null, callback, {}, null, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue