diff options
author | Robin Appelman <robin@icewind.nl> | 2015-09-03 14:08:00 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2015-09-03 14:08:00 +0200 |
commit | e9e42fff61a922f11a3b1014d810562537950b6a (patch) | |
tree | 4cb7543f7a1e4bbb4f907e09789135a60d1b18e0 /apps/files | |
parent | 5234090ee2d8cf41dca82d7794fb5f6c4844e466 (diff) | |
parent | 73c61941e28579dc92ea094fdf3272bcb68ae437 (diff) | |
download | nextcloud-server-e9e42fff61a922f11a3b1014d810562537950b6a.tar.gz nextcloud-server-e9e42fff61a922f11a3b1014d810562537950b6a.zip |
Merge pull request #18809 from owncloud/fix-tags-fileinfomodel
Tags in FileInfo map must be an array
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/tagsplugin.js | 8 | ||||
-rw-r--r-- | apps/files/tests/js/tagspluginspec.js | 15 |
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([]); + }); + }); }); |