summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-08-16 10:19:19 +0200
committerMorris Jobke <hey@morrisjobke.de>2014-08-16 10:19:19 +0200
commit549818633328b7320b766188982c07e8feb13708 (patch)
tree41c511f4f3bf204c422fa38926122871fe21586a /core
parentc132dd63577ff46a6742b602eea49ad2981c18b2 (diff)
parent607ea636be4a5a48b6abec8df3eaefe20fe4a1ba (diff)
downloadnextcloud-server-549818633328b7320b766188982c07e8feb13708.tar.gz
nextcloud-server-549818633328b7320b766188982c07e8feb13708.zip
Merge pull request #10447 from owncloud/share-foldericonfix
Fixed folder icon update routine when share owner exists
Diffstat (limited to 'core')
-rw-r--r--core/js/share.js2
-rw-r--r--core/js/tests/specHelper.js24
-rw-r--r--core/js/tests/specs/shareSpec.js47
3 files changed, 71 insertions, 2 deletions
diff --git a/core/js/share.js b/core/js/share.js
index f6165602f6c..99a767b47f2 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -231,7 +231,7 @@ OC.Share={
var shareFolderIcon;
var image = OC.imagePath('core', 'actions/share');
// update folder icon
- if (type === 'dir' && (hasShares || hasLink)) {
+ if (type === 'dir' && (hasShares || hasLink || owner)) {
if (hasLink) {
shareFolderIcon = OC.imagePath('core', 'filetypes/folder-public');
}
diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js
index 3d208d9ef3f..66e5d3578b2 100644
--- a/core/js/tests/specHelper.js
+++ b/core/js/tests/specHelper.js
@@ -82,6 +82,26 @@ window.Snap.prototype = {
var fakeServer = null,
$testArea = null;
+ /**
+ * Utility functions for testing
+ */
+ var TestUtil = {
+ /**
+ * Returns the image URL set on the given element
+ * @param $el element
+ * @return {String} image URL
+ */
+ getImageUrl: function($el) {
+ // might be slightly different cross-browser
+ var url = $el.css('background-image');
+ var r = url.match(/url\(['"]?([^'")]*)['"]?\)/);
+ if (!r) {
+ return url;
+ }
+ return r[1];
+ }
+ };
+
beforeEach(function() {
// test area for elements that need absolute selector access or measure widths/heights
// which wouldn't work for detached or hidden elements
@@ -103,6 +123,10 @@ window.Snap.prototype = {
// make it globally available, so that other tests can define
// custom responses
window.fakeServer = fakeServer;
+
+ if (!OC.TestUtil) {
+ OC.TestUtil = TestUtil;
+ }
});
afterEach(function() {
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 893f816833b..1fd36dfff04 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -562,7 +562,52 @@ describe('OC.Share tests', function() {
});
});
- // TODO: add unit tests for folder icons
+ describe('displaying the folder icon', function() {
+ function checkIcon(expectedImage) {
+ var imageUrl = OC.TestUtil.getImageUrl($file.find('.filename'));
+ expectedIcon = OC.imagePath('core', expectedImage);
+ expect(imageUrl).toEqual(expectedIcon);
+ }
+
+ it('shows a plain folder icon for non-shared folders', function() {
+ $file.attr('data-type', 'dir');
+ OC.Share.markFileAsShared($file);
+
+ checkIcon('filetypes/folder');
+ });
+ it('shows a shared folder icon for folders shared with another user', function() {
+ $file.attr('data-type', 'dir');
+ OC.Share.markFileAsShared($file, true);
+
+ checkIcon('filetypes/folder-shared');
+ });
+ it('shows a shared folder icon for folders shared with the current user', function() {
+ $file.attr('data-type', 'dir');
+ $file.attr('data-share-owner', 'someoneelse');
+ OC.Share.markFileAsShared($file);
+
+ checkIcon('filetypes/folder-shared');
+ });
+ it('shows a link folder icon for folders shared with link', function() {
+ $file.attr('data-type', 'dir');
+ OC.Share.markFileAsShared($file, false, true);
+
+ checkIcon('filetypes/folder-public');
+ });
+ it('shows a link folder icon for folders shared with both link and another user', function() {
+ $file.attr('data-type', 'dir');
+ OC.Share.markFileAsShared($file, true, true);
+
+ checkIcon('filetypes/folder-public');
+ });
+ it('shows a link folder icon for folders reshared with link', function() {
+ $file.attr('data-type', 'dir');
+ $file.attr('data-share-owner', 'someoneelse');
+ OC.Share.markFileAsShared($file, false, true);
+
+ checkIcon('filetypes/folder-public');
+ });
+ });
// TODO: add unit tests for share recipients
});
});