[Pkg-owncloud-commits] [owncloud] 08/22: Fix share dropdown when links are not allowed

David Prévot taffit at moszumanska.debian.org
Fri Aug 29 14:48:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit c38fcb520a3431f2f20d06126e86e9a457b28a70
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Aug 21 13:49:02 2014 +0200

    Fix share dropdown when links are not allowed
    
    When links are not allowed, the email field does not exist and
    autocomplete returns null. This causes Javascript errors.
    
    The fix prevents entering the bogus block when links aren't allowed, as
    it doesn't make sense to enter it in such cases anyway.
    
    Backport of 98d06094e70d657907b139431624740acde3bbd9 from master
---
 core/js/share.js                 |  2 +-
 core/js/tests/specs/shareSpec.js | 26 ++++++++++++++++----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/core/js/share.js b/core/js/share.js
index 99a767b..f165237 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -503,7 +503,7 @@ OC.Share={
 					.append( insert )
 					.appendTo( ul );
 			};
-			if (link) {
+			if (link && linksAllowed) {
 				$('#email').autocomplete({
 					minLength: 1,
 					source: function (search, response) {
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 1fd36df..06c4b98 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -44,6 +44,12 @@ describe('OC.Share tests', function() {
 
 			autocompleteStub = sinon.stub($.fn, 'autocomplete', function() {
 				// dummy container with the expected attributes
+				if (!$(this).length) {
+					// simulate the real autocomplete that returns
+					// nothing at all when no element is specified
+					// (and potentially break stuff)
+					return null;
+				}
 				var $el = $('<div></div>').data('ui-autocomplete', {});
 				return $el;
 			});
@@ -60,7 +66,7 @@ describe('OC.Share tests', function() {
 				'file',
 			   	123,
 			   	$container,
-				'http://localhost/dummylink',
+				true,
 				31,
 				'shared_file_name.txt'
 			);
@@ -73,7 +79,7 @@ describe('OC.Share tests', function() {
 				'file',
 			   	123,
 			   	$container,
-				'http://localhost/dummylink',
+				true,
 				31,
 				'shared_file_name.txt'
 			);
@@ -92,7 +98,7 @@ describe('OC.Share tests', function() {
 					'file',
 					123,
 					$container,
-					'http://localhost/dummylink',
+					true,		
 					31,
 					'shared_file_name.txt'
 				);
@@ -104,7 +110,7 @@ describe('OC.Share tests', function() {
 					'file',
 					123,
 					$container,
-					'http://localhost/dummylink',
+					true,		
 					31,
 					'shared_file_name.txt'
 				);
@@ -138,7 +144,7 @@ describe('OC.Share tests', function() {
 					'file',
 					123,
 					$container,
-					'http://localhost/dummylink',
+					true,
 					31,
 					'folder'
 				);
@@ -176,7 +182,7 @@ describe('OC.Share tests', function() {
 					'file',
 					456, // another file
 					$container,
-					'http://localhost/dummylink',
+					true,
 					31,
 					'folder'
 				);
@@ -230,7 +236,7 @@ describe('OC.Share tests', function() {
 					'folder',
 					123,
 					$container,
-					'http://localhost/dummylink',
+					true,
 					31,
 					'folder'
 				);
@@ -245,7 +251,7 @@ describe('OC.Share tests', function() {
 					'file',
 					456,
 					$container,
-					'http://localhost/dummylink',
+					true,
 					31,
 					'file_in_folder.txt'
 				);
@@ -266,7 +272,7 @@ describe('OC.Share tests', function() {
 						'file',
 						123,
 						$container,
-						'http://localhost/dummylink',
+						true,
 						31,
 						'folder'
 					);
@@ -407,7 +413,7 @@ describe('OC.Share tests', function() {
 					'file',
 					123,
 					$container,
-					'http://localhost/dummylink',
+					true,
 					31,
 					'shared_file_name.txt'
 				);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list