Skip to content

Commit

Permalink
Merge pull request #18809 from owncloud/fix-tags-fileinfomodel
Browse files Browse the repository at this point in the history
Tags in FileInfo map must be an array
  • Loading branch information
icewind1991 committed Sep 3, 2015
2 parents 5234090 + 73c6194 commit e9e42ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/files/js/tagsplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
},
Expand Down
15 changes: 15 additions & 0 deletions apps/files/tests/js/tagspluginspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
});
});
});

0 comments on commit e9e42ff

Please sign in to comment.