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

Commit ff228fb

Browse files
gkalpakpetebacondarwin
authored andcommitted
revert: fix($resource): allow XHR request to be cancelled via timeout promise
This reverts commit 7170f9d. Fixes part of #13393.
1 parent 8709539 commit ff228fb

File tree

2 files changed

+3
-42
lines changed

2 files changed

+3
-42
lines changed

src/ngResource/resource.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -568,17 +568,8 @@ angular.module('ngResource', ['ng']).
568568
undefined;
569569

570570
forEach(action, function(value, key) {
571-
switch (key) {
572-
default:
573-
httpConfig[key] = copy(value);
574-
break;
575-
case 'params':
576-
case 'isArray':
577-
case 'interceptor':
578-
break;
579-
case 'timeout':
580-
httpConfig[key] = value;
581-
break;
571+
if (key != 'params' && key != 'isArray' && key != 'interceptor') {
572+
httpConfig[key] = copy(value);
582573
}
583574
});
584575

test/ngResource/resourceSpec.js

+1-31
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ describe("resource", function() {
13081308
});
13091309

13101310
describe('resource', function() {
1311-
var $httpBackend, $resource, $q;
1311+
var $httpBackend, $resource;
13121312

13131313
beforeEach(module(function($exceptionHandlerProvider) {
13141314
$exceptionHandlerProvider.mode('log');
@@ -1319,7 +1319,6 @@ describe('resource', function() {
13191319
beforeEach(inject(function($injector) {
13201320
$httpBackend = $injector.get('$httpBackend');
13211321
$resource = $injector.get('$resource');
1322-
$q = $injector.get('$q');
13231322
}));
13241323

13251324

@@ -1357,34 +1356,5 @@ describe('resource', function() {
13571356
);
13581357
});
13591358

1360-
it('should cancel the request if timeout promise is resolved', function() {
1361-
var canceler = $q.defer();
1362-
1363-
$httpBackend.when('GET', '/CreditCard').respond({data: '123'});
1364-
1365-
var CreditCard = $resource('/CreditCard', {}, {
1366-
query: {
1367-
method: 'GET',
1368-
timeout: canceler.promise
1369-
}
1370-
});
1371-
1372-
CreditCard.query();
1373-
1374-
canceler.resolve();
1375-
expect($httpBackend.flush).toThrow(new Error("No pending request to flush !"));
1376-
1377-
canceler = $q.defer();
1378-
CreditCard = $resource('/CreditCard', {}, {
1379-
query: {
1380-
method: 'GET',
1381-
timeout: canceler.promise
1382-
}
1383-
});
1384-
1385-
CreditCard.query();
1386-
expect($httpBackend.flush).not.toThrow();
1387-
});
1388-
13891359

13901360
});

0 commit comments

Comments
 (0)