Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-05-20 18:01:34 +0400
committerVincent Petry <pvince81@owncloud.com>2014-05-30 12:06:29 +0400
commitef59c69dc822c9ff69c564c41e0dfdce142b9cdf (patch)
treea99667ab22daba65cbbd77ac591fccac234f06eb /apps/files/tests/js
parentfa32243d84e1801c379a5e8956ba2f3de236c718 (diff)
Distinguish legacy file actions from regular file actions
Legacy file actions are registered by legacy apps through window.FileActions.register(). These actions can only be used by the main file list ("all files") because legacy apps can only deal with a single list / container. New file actions of compatible apps must be registered through OCA.Files.fileActions. These will be used for other lists like the sharing overview. Fixed versions and sharing actions to use OCA.Files.fileActions, which makes them available in the sharing overview list.
Diffstat (limited to 'apps/files/tests/js')
-rw-r--r--apps/files/tests/js/appSpec.js53
-rw-r--r--apps/files/tests/js/fileactionsSpec.js7
-rw-r--r--apps/files/tests/js/filelistSpec.js5
3 files changed, 55 insertions, 10 deletions
diff --git a/apps/files/tests/js/appSpec.js b/apps/files/tests/js/appSpec.js
index 0e9abad6989..a9bbab03ecb 100644
--- a/apps/files/tests/js/appSpec.js
+++ b/apps/files/tests/js/appSpec.js
@@ -41,6 +41,10 @@ describe('OCA.Files.App tests', function() {
'</div>'
);
+ window.FileActions = new OCA.Files.FileActions();
+ OCA.Files.legacyFileActions = window.FileActions;
+ OCA.Files.fileActions = new OCA.Files.FileActions();
+
pushStateStub = sinon.stub(OC.Util.History, 'pushState');
parseUrlQueryStub = sinon.stub(OC.Util.History, 'parseUrlQuery');
parseUrlQueryStub.returns({});
@@ -51,8 +55,6 @@ describe('OCA.Files.App tests', function() {
App.navigation = null;
App.fileList = null;
App.files = null;
- App.fileActions.clear();
- App.fileActions = null;
pushStateStub.restore();
parseUrlQueryStub.restore();
@@ -64,6 +66,53 @@ describe('OCA.Files.App tests', function() {
expect(App.fileList.fileActions.actions.all).toBeDefined();
expect(App.fileList.$el.is('#app-content-files')).toEqual(true);
});
+ it('merges the legacy file actions with the default ones', function() {
+ var legacyActionStub = sinon.stub();
+ var actionStub = sinon.stub();
+ // legacy action
+ window.FileActions.register(
+ 'all',
+ 'LegacyTest',
+ OC.PERMISSION_READ,
+ OC.imagePath('core', 'actions/test'),
+ legacyActionStub
+ );
+ // legacy action to be overwritten
+ window.FileActions.register(
+ 'all',
+ 'OverwriteThis',
+ OC.PERMISSION_READ,
+ OC.imagePath('core', 'actions/test'),
+ legacyActionStub
+ );
+
+ // regular file actions
+ OCA.Files.fileActions.register(
+ 'all',
+ 'RegularTest',
+ OC.PERMISSION_READ,
+ OC.imagePath('core', 'actions/test'),
+ actionStub
+ );
+
+ // overwrite
+ OCA.Files.fileActions.register(
+ 'all',
+ 'OverwriteThis',
+ OC.PERMISSION_READ,
+ OC.imagePath('core', 'actions/test'),
+ actionStub
+ );
+
+ App.initialize();
+
+ var actions = App.fileList.fileActions.actions;
+ expect(actions.all.OverwriteThis.action).toBe(actionStub);
+ expect(actions.all.LegacyTest.action).toBe(legacyActionStub);
+ expect(actions.all.RegularTest.action).toBe(actionStub);
+ // default one still there
+ expect(actions.dir.Open.action).toBeDefined();
+ });
});
describe('URL handling', function() {
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index edd7e343884..fa634da08a2 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -21,7 +21,7 @@
describe('OCA.Files.FileActions tests', function() {
var $filesTable, fileList;
- var FileActions = OCA.Files.FileActions;
+ var FileActions;
beforeEach(function() {
// init horrible parameters
@@ -31,10 +31,11 @@ describe('OCA.Files.FileActions tests', function() {
// dummy files table
$filesTable = $body.append('<table id="filestable"></table>');
fileList = new OCA.Files.FileList($('#testArea'));
- FileActions.registerDefaultActions(fileList);
+ FileActions = new OCA.Files.FileActions();
+ FileActions.registerDefaultActions();
});
afterEach(function() {
- FileActions.clear();
+ FileActions = null;
fileList = undefined;
$('#dir, #permissions, #filestable').remove();
});
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 739ae599c65..a197fd5722c 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -21,7 +21,6 @@
describe('OCA.Files.FileList tests', function() {
var testFiles, alertStub, notificationStub, fileList;
- var FileActions = OCA.Files.FileActions;
/**
* Generate test file data
@@ -117,15 +116,11 @@ describe('OCA.Files.FileList tests', function() {
}];
fileList = new OCA.Files.FileList($('#app-content-files'));
- FileActions.clear();
- FileActions.registerDefaultActions(fileList);
- fileList.setFileActions(FileActions);
});
afterEach(function() {
testFiles = undefined;
fileList = undefined;
- FileActions.clear();
notificationStub.restore();
alertStub.restore();
});