diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-12-23 13:58:43 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-12-26 04:56:25 +0100 |
commit | ea40ade8adc115b45c09be0dc5148cfe2530079c (patch) | |
tree | 7fc0d30806e72d2e371eb8d86e57e791fec72d35 /apps/files/tests | |
parent | e37fa60784f94abb6715704ffcbd479c05938e3a (diff) | |
download | nextcloud-server-ea40ade8adc115b45c09be0dc5148cfe2530079c.tar.gz nextcloud-server-ea40ade8adc115b45c09be0dc5148cfe2530079c.zip |
Fix "fileActions.currentFile" not set before using it
When an empty area of a file row was clicked and the "Details" action
was executed "fileActions.currentFile" was not guaranteed to be set to
the appropriate object (it depended on the previous actions of the
user), so when it was used by "getCurrentMimeType()" and other
FileActions functions they may not work as expected. Now it is
explicitly set to the appropriate value before its use.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 83926b24fee..fc5a6c18f95 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2489,6 +2489,30 @@ describe('OCA.Files.FileList tests', function() { expect(context.fileActions).toBeDefined(); expect(context.dir).toEqual('/subdir'); }); + it('Clicking on an empty space of the file row will trigger the "Details" action', function() { + var detailsActionStub = sinon.stub(); + fileList.setFiles(testFiles); + // Override the "Details" action set internally by the FileList for + // easier testing. + fileList.fileActions.registerAction({ + mime: 'all', + name: 'Details', + permissions: OC.PERMISSION_NONE, + actionHandler: detailsActionStub + }); + // Ensure that the action works even if fileActions.currentFile is + // not set. + fileList.fileActions.currentFile = null; + var $tr = fileList.findFileEl('One.txt'); + $tr.find('td.filename a.name').click(); + expect(detailsActionStub.calledOnce).toEqual(true); + expect(detailsActionStub.getCall(0).args[0]).toEqual('One.txt'); + var context = detailsActionStub.getCall(0).args[1]; + expect(context.$file.is($tr)).toEqual(true); + expect(context.fileList).toBe(fileList); + expect(context.fileActions).toBe(fileList.fileActions); + expect(context.dir).toEqual('/subdir'); + }); it('redisplays actions when new actions have been registered', function() { var actionStub = sinon.stub(); var readyHandler = sinon.stub(); |