Merge pull request #18114 from owncloud/fix-delete-user-feedback

[user mgnt] fix delete user feedback on failure
This commit is contained in:
Morris Jobke 2015-08-19 16:10:55 +02:00
commit 8f00f103c6
2 changed files with 34 additions and 11 deletions

View File

@ -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}));
},
error: function (jqXHR) {
OC.dialogs.alert(jqXHR.responseJSON.data.message, t('settings', 'Unable to delete {objName}', {objName: dh.oidToDelete}));
dh.undoCallback(dh.oidToDelete);
}
}
});
};

View File

@ -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'}})
]);