Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,8 @@ var OC={
// sometimes "beforeunload" happens later, so need to defer the reload a bit
setTimeout(function() {
if (!self._userIsNavigatingAway && !self._reloadCalled) {
OC.reload();
OC.Notification.show(t('core', 'Problem loading page, reloading in 5 seconds'));
setTimeout(OC.reload, 5000);
// only call reload once
self._reloadCalled = true;
}
Expand Down
18 changes: 15 additions & 3 deletions core/js/tests/specs/coreSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,17 +935,21 @@ describe('Core base tests', function() {
});
describe('global ajax errors', function() {
var reloadStub, ajaxErrorStub, clock;
var notificationStub;
var waitTimeMs = 6000;

beforeEach(function() {
clock = sinon.useFakeTimers();
reloadStub = sinon.stub(OC, 'reload');
notificationStub = sinon.stub(OC.Notification, 'show');
// unstub the error processing method
ajaxErrorStub = OC._processAjaxError;
ajaxErrorStub.restore();
window.initCore();
});
afterEach(function() {
reloadStub.restore();
notificationStub.restore();
clock.restore();
});

Expand All @@ -970,7 +974,7 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);

// trigger timers
clock.tick(1000);
clock.tick(waitTimeMs);

if (expectedCall) {
expect(reloadStub.calledOnce).toEqual(true);
Expand All @@ -986,7 +990,7 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);

// trigger timers
clock.tick(1000);
clock.tick(waitTimeMs);

expect(reloadStub.calledOnce).toEqual(true);
});
Expand All @@ -997,9 +1001,17 @@ describe('Core base tests', function() {

$(document).trigger(new $.Event('ajaxError'), xhr);

clock.tick(1000);
clock.tick(waitTimeMs);
expect(reloadStub.notCalled).toEqual(true);
});
it('displays notification', function() {
var xhr = { status: 401 };

$(document).trigger(new $.Event('ajaxError'), xhr);

clock.tick(waitTimeMs);
expect(notificationStub.calledOnce).toEqual(true);
});
});
});