diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-08-19 16:10:55 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-08-19 16:10:55 +0200 |
commit | 8f00f103c6a802abd72eac9e769d83db76fd1166 (patch) | |
tree | 1d1008b83742f4db87df1a832a56e16a1d621077 /settings | |
parent | 5fd36d017ecdbce61dcf1c67ae04c8c0be81a4bf (diff) | |
parent | e350a8bfd070b3742e0c5e6cbb2b9a0e69d7473f (diff) | |
download | nextcloud-server-8f00f103c6a802abd72eac9e769d83db76fd1166.tar.gz nextcloud-server-8f00f103c6a802abd72eac9e769d83db76fd1166.zip |
Merge pull request #18114 from owncloud/fix-delete-user-feedback
[user mgnt] fix delete user feedback on failure
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/users/deleteHandler.js | 20 | ||||
-rw-r--r-- | settings/tests/js/users/deleteHandlerSpec.js | 27 |
2 files changed, 35 insertions, 12 deletions
diff --git a/settings/js/users/deleteHandler.js b/settings/js/users/deleteHandler.js index fcad39dd4cc..de87f901372 100644 --- a/settings/js/users/deleteHandler.js +++ b/settings/js/users/deleteHandler.js @@ -194,16 +194,16 @@ DeleteHandler.prototype.deleteEntry = function(keepNotification) { // FIXME: do not use synchronous ajax calls as they block the browser ! async: false, success: function (result) { - if (result.status === 'success') { - // Remove undo option, & remove user from table - - //TODO: following line - dh.removeCallback(dh.oidToDelete); - dh.canceled = true; - } else { - OC.dialogs.alert(result.data.message, t('settings', 'Unable to delete {objName}', {objName: dh.oidToDelete})); - dh.undoCallback(dh.oidToDelete); - } + // Remove undo option, & remove user from table + + //TODO: following line + dh.removeCallback(dh.oidToDelete); + dh.canceled = true; + }, + error: function (jqXHR) { + OC.dialogs.alert(jqXHR.responseJSON.data.message, t('settings', 'Unable to delete {objName}', {objName: dh.oidToDelete})); + dh.undoCallback(dh.oidToDelete); + } }); }; diff --git a/settings/tests/js/users/deleteHandlerSpec.js b/settings/tests/js/users/deleteHandlerSpec.js index c6d88b32411..371eae5941d 100644 --- a/settings/tests/js/users/deleteHandlerSpec.js +++ b/settings/tests/js/users/deleteHandlerSpec.js @@ -63,6 +63,17 @@ describe('DeleteHandler tests', function() { expect(fakeServer.requests.length).toEqual(0); }); it('deletes first entry and reshows notification on second delete', function() { + fakeServer.respondWith(/\/index\.php\/dummyendpoint.php\/some_uid/, [ + 204, + { 'Content-Type': 'application/json' }, + JSON.stringify({status: 'success'}) + ]); + fakeServer.respondWith(/\/index\.php\/dummyendpoint.php\/some_other_uid/, [ + 204, + { 'Content-Type': 'application/json' }, + JSON.stringify({status: 'success'}) + ]); + var handler = init(markCallback, removeCallback, undoCallback); handler.mark('some_uid'); @@ -79,7 +90,8 @@ describe('DeleteHandler tests', function() { expect(markCallback.calledTwice).toEqual(true); expect(markCallback.getCall(0).args[0]).toEqual('some_uid'); expect(markCallback.getCall(1).args[0]).toEqual('some_other_uid'); - expect(removeCallback.notCalled).toEqual(true); + // called only once, because it is called once the second user is deleted + expect(removeCallback.calledOnce).toEqual(true); expect(undoCallback.notCalled).toEqual(true); // previous one was delete @@ -88,6 +100,12 @@ describe('DeleteHandler tests', function() { expect(request.url).toEqual(OC.webroot + '/index.php/dummyendpoint.php/some_uid'); }); it('automatically deletes after timeout', function() { + fakeServer.respondWith(/\/index\.php\/dummyendpoint.php\/some_uid/, [ + 204, + { 'Content-Type': 'application/json' }, + JSON.stringify({status: 'success'}) + ]); + var handler = init(markCallback, removeCallback, undoCallback); handler.mark('some_uid'); @@ -101,6 +119,11 @@ describe('DeleteHandler tests', function() { expect(request.url).toEqual(OC.webroot + '/index.php/dummyendpoint.php/some_uid'); }); it('deletes when deleteEntry is called', function() { + fakeServer.respondWith(/\/index\.php\/dummyendpoint.php\/some_uid/, [ + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify({status: 'success'}) + ]); var handler = init(markCallback, removeCallback, undoCallback); handler.mark('some_uid'); @@ -157,7 +180,7 @@ describe('DeleteHandler tests', function() { // stub t to avoid extra calls var tStub = sinon.stub(window, 't').returns('text'); fakeServer.respondWith(/\/index\.php\/dummyendpoint.php\/some_uid/, [ - 200, + 403, { 'Content-Type': 'application/json' }, JSON.stringify({status: 'error', data: {message: 'test error'}}) ]); |