diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-20 11:44:18 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-05-30 10:06:29 +0200 |
commit | 06e53b359ac806b9103cb617e7a6bad8cbadb519 (patch) | |
tree | 777755a967bce2f8f6116ea47a628a92ee7f89c6 /apps/files/tests | |
parent | d21b8108c88b33dbef465c7afc07613ab6466751 (diff) | |
download | nextcloud-server-06e53b359ac806b9103cb617e7a6bad8cbadb519.tar.gz nextcloud-server-06e53b359ac806b9103cb617e7a6bad8cbadb519.zip |
Added "dir" in file actions handler context and fixed versions
Added "dir" in file actions handler context so that handlers can know
what the path of the file was without having to look it up from the file
list.
Fixed versions app to use the context.dir instead of the old $('#dir')
element. This makes the versions popup work in the sharing overview.
Diffstat (limited to 'apps/files/tests')
-rw-r--r-- | apps/files/tests/js/fileactionsSpec.js | 8 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 26 |
2 files changed, 34 insertions, 0 deletions
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index 519a31b3fce..edd7e343884 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -152,5 +152,13 @@ describe('OCA.Files.FileActions tests', function() { expect(context.$file.is($tr)).toEqual(true); expect(context.fileList).toBeDefined(); expect(context.fileActions).toBeDefined(); + expect(context.dir).toEqual('/subdir'); + + // when data-path is defined + actionStub.reset(); + $tr.attr('data-path', '/somepath'); + $tr.find('.action-test').click(); + context = actionStub.getCall(0).args[1]; + expect(context.dir).toEqual('/somepath'); }); }); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 3dd715254e4..739ae599c65 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1526,6 +1526,32 @@ describe('OCA.Files.FileList tests', function() { expect(fileList.getSelectedFiles()).toEqual([]); }); }); + describe('File actions', function() { + it('Clicking on a file name will trigger default action', function() { + var actionStub = sinon.stub(); + fileList.setFiles(testFiles); + fileList.fileActions.register( + 'text/plain', + 'Test', + OC.PERMISSION_ALL, + function() { + // Specify icon for hitory button + return OC.imagePath('core','actions/history'); + }, + actionStub + ); + fileList.fileActions.setDefault('text/plain', 'Test'); + var $tr = fileList.findFileEl('One.txt'); + $tr.find('td.filename>a.name').click(); + expect(actionStub.calledOnce).toEqual(true); + expect(actionStub.getCall(0).args[0]).toEqual('One.txt'); + var context = actionStub.getCall(0).args[1]; + expect(context.$file.is($tr)).toEqual(true); + expect(context.fileList).toBeDefined(); + expect(context.fileActions).toBeDefined(); + expect(context.dir).toEqual('/subdir'); + }); + }); describe('Sorting files', function() { it('Sorts by name by default', function() { fileList.reload(); |