Skip to content

Commit

Permalink
fix(ngTableParams): reload is never triggered once reload has failed …
Browse files Browse the repository at this point in the history
…once
  • Loading branch information
ccrowhurstram committed Oct 18, 2015
1 parent f2486b9 commit 4369926
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/scripts/ngTableParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@
* @name NgTableParams#isDataReloadRequired
* @description Return true when a change to this `NgTableParams` instance should require the reload method
* to be run so as to ensure the data presented to the user reflects the `NgTableParams`
*
* Note that this method will return false when the reload method has run but fails. In this case
* `hasErrorState` will return true.
*/
this.isDataReloadRequired = function(){
// note: using != as want to treat null and undefined the same
Expand Down Expand Up @@ -581,8 +584,6 @@
return data;
}).catch(function(reason){
errParamsMemento = prevParamsMemento;
prevParamsMemento = null;
isCommittedDataset = false;
// "rethrow"
return $q.reject(reason);
});
Expand Down
6 changes: 3 additions & 3 deletions test/tableParamsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,13 +1009,13 @@ describe('NgTableParams', function () {
expect(tp.isDataReloadRequired()).toBe(false);
});

it('should return true when getData fails', inject(function($q){
it('should return false when getData fails', inject(function($q){
tp.settings({ getData: function(){
return $q.reject('bad response');
}});
tp.reload();
scope.$digest();
expect(tp.isDataReloadRequired()).toBe(true);
expect(tp.isDataReloadRequired()).toBe(false);
}));

it('should detect direct changes to parameters', inject(function($q){
Expand Down Expand Up @@ -1157,7 +1157,7 @@ describe('NgTableParams', function () {
}});
tp.reload();
scope.$digest();
expect(tp.hasFilterChanges()).toBe(true);
expect(tp.hasFilterChanges()).toBe(false);
}));

it('should detect direct changes to filters', inject(function($q){
Expand Down
2 changes: 1 addition & 1 deletion test/tableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ describe('ng-table', function() {
scope.$digest();

// then
expect(tp.isDataReloadRequired()).toBe(true);
expect(tp.isDataReloadRequired()).toBe(false);
expect(tp.settings().getData.calls.count()).toBe(2);
}));

Expand Down

0 comments on commit 4369926

Please sign in to comment.