mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-20 16:30:26 +00:00
fix($httpBackend): Set current url, if not defined or empty string
Reason to fix this was the fact that with undefined url, it ended up with weird exception (Cannot call method 'replace' of undefined), which was more confusing than helpful. jQuery.ajax() does request to current url, if url is not specified, so I decided for this solution.
This commit is contained in:
parent
d6e3e1baab
commit
3171f21591
2 changed files with 12 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, body, locati
|
|||
// TODO(vojta): fix the signature
|
||||
return function(method, url, post, callback, headers, timeout) {
|
||||
$browser.$$incOutstandingRequestCount();
|
||||
url = url || $browser.url();
|
||||
|
||||
if (lowercase(method) == 'jsonp') {
|
||||
var callbackId = '_' + (callbacks.counter++).toString(36);
|
||||
|
|
|
|||
|
|
@ -168,6 +168,17 @@ describe('$httpBackend', function() {
|
|||
});
|
||||
|
||||
|
||||
it('should set url to current location if not specified or empty string', function() {
|
||||
$backend('JSONP', undefined, null, callback);
|
||||
expect($browser.$$scripts[0].url).toBe($browser.url());
|
||||
$browser.$$scripts.shift();
|
||||
|
||||
$backend('JSONP', '', null, callback);
|
||||
expect($browser.$$scripts[0].url).toBe($browser.url());
|
||||
$browser.$$scripts.shift();
|
||||
});
|
||||
|
||||
|
||||
// TODO(vojta): test whether it fires "async-start"
|
||||
// TODO(vojta): test whether it fires "async-end" on both success and error
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue