fix($resource): do not throw when calling old $cancelRequest()
Closes #16037
This commit is contained in:
committed by
Georgios Kalpakas
parent
ac57a25cd9
commit
01d6a47e91
@@ -830,7 +830,9 @@ angular.module('ngResource', ['ng']).
|
||||
|
||||
function cancelRequest(value) {
|
||||
promise.catch(noop);
|
||||
timeoutDeferred.resolve(value);
|
||||
if (timeoutDeferred !== null) {
|
||||
timeoutDeferred.resolve(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2102,6 +2102,25 @@ describe('cancelling requests', function() {
|
||||
|
||||
expect(creditCard.$cancelRequest).toBe(noop);
|
||||
});
|
||||
|
||||
it('should not break when calling old `$cancelRequest` after the response arrives', function() {
|
||||
$httpBackend.whenGET('/CreditCard').respond({});
|
||||
|
||||
var CreditCard = $resource('/CreditCard', {}, {
|
||||
get: {
|
||||
method: 'GET',
|
||||
cancellable: true
|
||||
}
|
||||
});
|
||||
|
||||
var creditCard = CreditCard.get();
|
||||
var cancelRequest = creditCard.$cancelRequest;
|
||||
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(cancelRequest).not.toBe(noop);
|
||||
expect(cancelRequest).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('configuring `cancellable` on the provider', function() {
|
||||
|
||||
Reference in New Issue
Block a user