aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-09-02 19:02:06 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-03 13:01:14 +0200
commit73c61941e28579dc92ea094fdf3272bcb68ae437 (patch)
treeefa62f143fa29487d6b9b5ec7fa76faf4687f8c2 /apps
parent8684420d0a503f5c913343eca838b3a7dc903506 (diff)
downloadnextcloud-server-73c61941e28579dc92ea094fdf3272bcb68ae437.tar.gz
nextcloud-server-73c61941e28579dc92ea094fdf3272bcb68ae437.zip
Tags in FileInfo map must be an array
Fixes FileList.elementToFile to make an array for the tags instead of keeping the original joined string
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/tagsplugin.js8
-rw-r--r--apps/files/tests/js/tagspluginspec.js15
2 files changed, 22 insertions, 1 deletions
diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js
index ed1105a1706..609e38ca9a9 100644
--- a/apps/files/js/tagsplugin.js
+++ b/apps/files/js/tagsplugin.js
@@ -150,7 +150,13 @@
var oldElementToFile = fileList.elementToFile;
fileList.elementToFile = function($el) {
var fileInfo = oldElementToFile.apply(this, arguments);
- fileInfo.tags = $el.attr('data-tags') || [];
+ var tags = $el.attr('data-tags');
+ if (_.isUndefined(tags)) {
+ tags = '';
+ }
+ tags = tags.split('|');
+ tags = _.without(tags, '');
+ fileInfo.tags = tags;
return fileInfo;
};
},
diff --git a/apps/files/tests/js/tagspluginspec.js b/apps/files/tests/js/tagspluginspec.js
index 5309973cf4f..950fb754253 100644
--- a/apps/files/tests/js/tagspluginspec.js
+++ b/apps/files/tests/js/tagspluginspec.js
@@ -112,4 +112,19 @@ describe('OCA.Files.TagsPlugin tests', function() {
expect($action.find('img').attr('src')).toEqual(OC.imagePath('core', 'actions/star'));
});
});
+ describe('elementToFile', function() {
+ it('returns tags', function() {
+ fileList.setFiles(testFiles);
+ var $tr = fileList.findFileEl('One.txt');
+ var data = fileList.elementToFile($tr);
+ expect(data.tags).toEqual(['tag1', 'tag2']);
+ });
+ it('returns empty array when no tags present', function() {
+ delete testFiles[0].tags;
+ fileList.setFiles(testFiles);
+ var $tr = fileList.findFileEl('One.txt');
+ var data = fileList.elementToFile($tr);
+ expect(data.tags).toEqual([]);
+ });
+ });
});