]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed broken delete file action
authorVincent Petry <pvince81@owncloud.com>
Tue, 1 Apr 2014 14:09:48 +0000 (16:09 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 1 Apr 2014 14:09:48 +0000 (16:09 +0200)
apps/files/js/fileactions.js
apps/files/tests/js/fileactionsSpec.js

index a7d1fa9d8a2785b266fba23be6f474c31e08c7a3..732690f047a4152c95bff8b98830be3baa8acd05 100644 (file)
@@ -180,7 +180,7 @@ var FileActions = {
                        }
                        var element = $(html);
                        element.data('action', actions['Delete']);
-                       element.on('click', {a: null, elem: parent, actionFunc: actions['Delete']}, actionHandler);
+                       element.on('click', {a: null, elem: parent, actionFunc: actions['Delete'].action}, actionHandler);
                        parent.parent().children().last().append(element);
                }
 
index ef7ddcb874ab143c5901bb4e236e52ca4ec4ab0b..80c04b5b242d5dc05dd90ebe660d771dee1b293b 100644 (file)
@@ -38,15 +38,17 @@ describe('FileActions tests', function() {
                var $tr = FileList.addFile('testName.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
 
                // no actions before call
-               expect($tr.find('.action[data-action=Download]').length).toEqual(0);
-               expect($tr.find('.action[data-action=Rename]').length).toEqual(0);
+               expect($tr.find('.action.action-download').length).toEqual(0);
+               expect($tr.find('.action.action-rename').length).toEqual(0);
                expect($tr.find('.action.delete').length).toEqual(0);
 
                FileActions.display($tr.find('td.filename'), true);
 
                // actions defined after cal
-               expect($tr.find('.action[data-action=Download]').length).toEqual(1);
-               expect($tr.find('.nametext .action[data-action=Rename]').length).toEqual(1);
+               expect($tr.find('.action.action-download').length).toEqual(1);
+               expect($tr.find('.action.action-download').attr('data-action')).toEqual('Download');
+               expect($tr.find('.nametext .action.action-rename').length).toEqual(1);
+               expect($tr.find('.nametext .action.action-rename').attr('data-action')).toEqual('Rename');
                expect($tr.find('.action.delete').length).toEqual(1);
        });
        it('calling display() twice correctly replaces file actions', function() {
@@ -56,8 +58,8 @@ describe('FileActions tests', function() {
                FileActions.display($tr.find('td.filename'), true);
 
                // actions defined after cal
-               expect($tr.find('.action[data-action=Download]').length).toEqual(1);
-               expect($tr.find('.nametext .action[data-action=Rename]').length).toEqual(1);
+               expect($tr.find('.action.action-download').length).toEqual(1);
+               expect($tr.find('.nametext .action.action-rename').length).toEqual(1);
                expect($tr.find('.action.delete').length).toEqual(1);
        });
        it('redirects to download URL when clicking download', function() {
@@ -66,10 +68,20 @@ describe('FileActions tests', function() {
                var $tr = FileList.addFile('test download File.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
                FileActions.display($tr.find('td.filename'), true);
 
-               $tr.find('.action[data-action=Download]').click();
+               $tr.find('.action-download').click();
 
                expect(redirectStub.calledOnce).toEqual(true);
                expect(redirectStub.getCall(0).args[0]).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=test%20download%20File.txt');
                redirectStub.restore();
        });
+       it('deletes file when clicking delete', function() {
+               var deleteStub = sinon.stub(FileList, 'do_delete');
+               var $tr = FileList.addFile('test delete File.txt', 1234, new Date());
+               FileActions.display($tr.find('td.filename'), true);
+
+               $tr.find('.action.delete').click();
+
+               expect(deleteStub.calledOnce).toEqual(true);
+               deleteStub.restore();
+       });
 });