Skip to content
Snippets Groups Projects
Commit 6458b5ad authored by Lukas Reschke's avatar Lukas Reschke Committed by GitHub
Browse files

Merge pull request #2414 from nextcloud/version_previews

Fix empty version previews
parents cd52b98e 66a77a88
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -467,6 +467,7 @@ class Storage { ...@@ -467,6 +467,7 @@ class Storage {
$versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'] . '/' . $filename); $versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'] . '/' . $filename);
$versions[$key]['name'] = $versionedFile; $versions[$key]['name'] = $versionedFile;
$versions[$key]['size'] = $view->filesize($dir . '/' . $entryName); $versions[$key]['size'] = $view->filesize($dir . '/' . $entryName);
$versions[$key]['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($versionedFile);
} }
} }
} }
......
...@@ -24,14 +24,16 @@ describe('OCA.Versions.VersionsTabView', function() { ...@@ -24,14 +24,16 @@ describe('OCA.Versions.VersionsTabView', function() {
timestamp: time1, timestamp: time1,
name: 'some file.txt', name: 'some file.txt',
size: 140, size: 140,
fullPath: '/subdir/some file.txt' fullPath: '/subdir/some file.txt',
mimetype: 'text/plain'
}); });
var version2 = new VersionModel({ var version2 = new VersionModel({
id: time2, id: time2,
timestamp: time2, timestamp: time2,
name: 'some file.txt', name: 'some file.txt',
size: 150, size: 150,
fullPath: '/subdir/some file.txt' fullPath: '/subdir/some file.txt',
mimetype: 'text/plain'
}); });
testVersions = [version1, version2]; testVersions = [version1, version2];
...@@ -80,14 +82,14 @@ describe('OCA.Versions.VersionsTabView', function() { ...@@ -80,14 +82,14 @@ describe('OCA.Versions.VersionsTabView', function() {
expect($item.find('.versiondate').text()).toEqual('seconds ago'); expect($item.find('.versiondate').text()).toEqual('seconds ago');
expect($item.find('.size').text()).toEqual('< 1 KB'); expect($item.find('.size').text()).toEqual('< 1 KB');
expect($item.find('.revertVersion').length).toEqual(1); expect($item.find('.revertVersion').length).toEqual(1);
expect($item.find('.preview').attr('src')).toEqual(version1.getPreviewUrl()); expect($item.find('.preview').attr('src')).toEqual('http://localhost/core/img/filetypes/text.svg');
$item = $versions.eq(1); $item = $versions.eq(1);
expect($item.find('.downloadVersion').attr('href')).toEqual(version2.getDownloadUrl()); expect($item.find('.downloadVersion').attr('href')).toEqual(version2.getDownloadUrl());
expect($item.find('.versiondate').text()).toEqual('2 days ago'); expect($item.find('.versiondate').text()).toEqual('2 days ago');
expect($item.find('.size').text()).toEqual('< 1 KB'); expect($item.find('.size').text()).toEqual('< 1 KB');
expect($item.find('.revertVersion').length).toEqual(1); expect($item.find('.revertVersion').length).toEqual(1);
expect($item.find('.preview').attr('src')).toEqual(version2.getPreviewUrl()); expect($item.find('.preview').attr('src')).toEqual('http://localhost/core/img/filetypes/text.svg');
}); });
it('does not render revert button when no update permissions', function() { it('does not render revert button when no update permissions', function() {
...@@ -104,13 +106,13 @@ describe('OCA.Versions.VersionsTabView', function() { ...@@ -104,13 +106,13 @@ describe('OCA.Versions.VersionsTabView', function() {
expect($item.find('.downloadVersion').attr('href')).toEqual(version1.getDownloadUrl()); expect($item.find('.downloadVersion').attr('href')).toEqual(version1.getDownloadUrl());
expect($item.find('.versiondate').text()).toEqual('seconds ago'); expect($item.find('.versiondate').text()).toEqual('seconds ago');
expect($item.find('.revertVersion').length).toEqual(0); expect($item.find('.revertVersion').length).toEqual(0);
expect($item.find('.preview').attr('src')).toEqual(version1.getPreviewUrl()); expect($item.find('.preview').attr('src')).toEqual('http://localhost/core/img/filetypes/text.svg');
$item = $versions.eq(1); $item = $versions.eq(1);
expect($item.find('.downloadVersion').attr('href')).toEqual(version2.getDownloadUrl()); expect($item.find('.downloadVersion').attr('href')).toEqual(version2.getDownloadUrl());
expect($item.find('.versiondate').text()).toEqual('2 days ago'); expect($item.find('.versiondate').text()).toEqual('2 days ago');
expect($item.find('.revertVersion').length).toEqual(0); expect($item.find('.revertVersion').length).toEqual(0);
expect($item.find('.preview').attr('src')).toEqual(version2.getPreviewUrl()); expect($item.find('.preview').attr('src')).toEqual('http://localhost/core/img/filetypes/text.svg');
}); });
}); });
...@@ -156,7 +158,8 @@ describe('OCA.Versions.VersionsTabView', function() { ...@@ -156,7 +158,8 @@ describe('OCA.Versions.VersionsTabView', function() {
timestamp: time3, timestamp: time3,
name: 'some file.txt', name: 'some file.txt',
size: 54, size: 54,
fullPath: '/subdir/some file.txt' fullPath: '/subdir/some file.txt',
mimetype: 'text/plain'
}); });
tabView.collection.add(version3); tabView.collection.add(version3);
...@@ -167,7 +170,7 @@ describe('OCA.Versions.VersionsTabView', function() { ...@@ -167,7 +170,7 @@ describe('OCA.Versions.VersionsTabView', function() {
expect($item.find('.downloadVersion').attr('href')).toEqual(version3.getDownloadUrl()); expect($item.find('.downloadVersion').attr('href')).toEqual(version3.getDownloadUrl());
expect($item.find('.versiondate').text()).toEqual('7 days ago'); expect($item.find('.versiondate').text()).toEqual('7 days ago');
expect($item.find('.revertVersion').length).toEqual(1); expect($item.find('.revertVersion').length).toEqual(1);
expect($item.find('.preview').attr('src')).toEqual(version3.getPreviewUrl()); expect($item.find('.preview').attr('src')).toEqual('http://localhost/core/img/filetypes/text.svg');
}); });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment