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

Commit

Permalink
fix(ngResource): canceling XHR request using promise - refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
netman92 committed Aug 24, 2015
1 parent 2955bbf commit 2ac00f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/ngResource/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,17 @@ angular.module('ngResource', ['ng']).
undefined;

forEach(action, function(value, key) {
if (key != 'params' && key != 'isArray' && key != 'interceptor' && key != 'timeout') {
httpConfig[key] = copy(value);
} else if (key == 'timeout') {
httpConfig[key] = value;
switch (key) {
default:
httpConfig[key] = copy(value);
break;
case 'params':
case 'isArray':
case 'interceptor':
break;
case 'timeout':
httpConfig[key] = value;
break;
}
});

Expand Down
2 changes: 1 addition & 1 deletion test/ngResource/resourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ describe('resource', function() {
);
});

it('If timeout promise is resolved, cancel the request', function() {
it('should cancel the request if timeout promise is resolved', function() {
var canceler = $q.defer();

$httpBackend.when('GET', '/CreditCard').respond({data: '123'});
Expand Down

0 comments on commit 2ac00f5

Please sign in to comment.