From 0c1b764826a04437504d2cf70ffaa20c4228ffb2 Mon Sep 17 00:00:00 2001 From: Michael Jobst Date: Thu, 10 Nov 2016 09:13:25 +0100 Subject: [PATCH] share api expanded by tags (#26583) * share api expanded by tags * Modified files_sharing JS Unit tests * modified tests. renamed request parameter. refactoring * Update Share20OCS.php Added missing function description * Update Helper.php Added missing function description * Update Helper.php implicit boolean conversion to !empty() * Update Share20OCSTest.php --- apps/files/ajax/list.php | 1 - apps/files/js/tagsplugin.js | 7 +- apps/files/lib/Helper.php | 27 +++- apps/files_sharing/js/sharedfilelist.js | 15 ++- apps/files_sharing/lib/API/Share20OCS.php | 121 ++++++++++-------- .../tests/API/Share20OCSTest.php | 88 ++++++------- .../tests/js/sharedfilelistSpec.js | 60 ++++++--- 7 files changed, 193 insertions(+), 126 deletions(-) diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 0bda6e0631b5..541e34abbff4 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -70,7 +70,6 @@ $files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection); } - $files = \OCA\Files\Helper::populateTags($files); $data['directory'] = $dir; $data['files'] = \OCA\Files\Helper::formatFileInfos($files); $data['permissions'] = $permissions; diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 3c0a231d0033..857e15946ccc 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -70,7 +70,11 @@ allowedLists: [ 'files', - 'favorites' + 'favorites', + 'systemtags', + 'shares.self', + 'shares.others', + 'shares.link' ], _extendFileActions: function(fileActions) { @@ -238,4 +242,3 @@ })(OCA); OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin); - diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 11d49a937550..9b7e66f8bedd 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -207,19 +207,40 @@ public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = * Populate the result set with file tags * * @param array $fileList + * @param string $fileIdentifier identifier attribute name for values in $fileList * @return array file list populated with tags */ - public static function populateTags(array $fileList) { + public static function populateTags(array $fileList, $fileIdentifier = 'fileid') { $filesById = []; foreach ($fileList as $fileData) { - $filesById[$fileData['fileid']] = $fileData; + $filesById[$fileData[$fileIdentifier]] = $fileData; } $tagger = \OC::$server->getTagManager()->load('files'); $tags = $tagger->getTagsForObjects(array_keys($filesById)); - if ($tags) { + + if (!is_array($tags)) { + throw new \UnexpectedValueException('$tags must be an array'); + } + + if (!empty($tags)) { foreach ($tags as $fileId => $fileTags) { $filesById[$fileId]['tags'] = $fileTags; } + + foreach ($filesById as $key => $fileWithTags) { + foreach($fileList as $key2 => $file){ + if( $file[$fileIdentifier] == $key){ + $fileList[$key2] = $fileWithTags; + } + } + } + + foreach ($fileList as $key => $file) { + if (!array_key_exists('tags', $file)) { + $fileList[$key]['tags'] = []; + } + } + } return $fileList; } diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index dccd6027b02d..67bd5b5023a4 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -56,7 +56,6 @@ if (options && options.linksOnly) { this._linksOnly = true; } - OC.Plugins.attach('OCA.Sharing.FileList', this); }, _renderRow: function() { @@ -83,7 +82,7 @@ // add row with expiration date for link only shares - influenced by _createRow of filelist if (this._linksOnly) { var expirationTimestamp = 0; - if(fileData.shares[0].expiration !== null) { + if(fileData.shares && fileData.shares[0].expiration !== null) { expirationTimestamp = moment(fileData.shares[0].expiration).valueOf(); } $tr.attr('data-expiration', expirationTimestamp); @@ -169,7 +168,8 @@ /* jshint camelcase: false */ data: { format: 'json', - shared_with_me: !!this._sharedWithUser + shared_with_me: !!this._sharedWithUser, + include_tags: true }, type: 'GET', beforeSend: function(xhr) { @@ -183,7 +183,8 @@ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares', /* jshint camelcase: false */ data: { - format: 'json' + format: 'json', + include_tags: true }, type: 'GET', beforeSend: function(xhr) { @@ -238,7 +239,8 @@ type: share.type, id: share.file_id, path: OC.dirname(share.mountpoint), - permissions: share.permissions + permissions: share.permissions, + tags: share.tags || [] }; file.shares = [{ @@ -276,7 +278,8 @@ var file = { id: share.file_source, icon: OC.MimeType.getIconUrl(share.mimetype), - mimetype: share.mimetype + mimetype: share.mimetype, + tags: share.tags || [] }; if (share.item_type === 'folder') { file.type = 'dir'; diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index 0b7e9866eefe..4c6b5f2942c9 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -174,87 +174,87 @@ protected function formatShare(\OCP\Share\IShare $share) { * Get a specific share by id * * @param string $id - * @return \OC_OCS_Result + * @return \OC\OCS\Result */ public function getShare($id) { if (!$this->shareManager->shareApiEnabled()) { - return new \OC_OCS_Result(null, 404, $this->l->t('Share API is disabled')); + return new \OC\OCS\Result(null, 404, $this->l->t('Share API is disabled')); } try { $share = $this->getShareById($id); } catch (ShareNotFound $e) { - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); } if ($this->canAccessShare($share)) { try { $share = $this->formatShare($share); - return new \OC_OCS_Result([$share]); + return new \OC\OCS\Result([$share]); } catch (NotFoundException $e) { //Fall trough } } - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); } /** * Delete a share * * @param string $id - * @return \OC_OCS_Result + * @return \OC\OCS\Result */ public function deleteShare($id) { if (!$this->shareManager->shareApiEnabled()) { - return new \OC_OCS_Result(null, 404, $this->l->t('Share API is disabled')); + return new \OC\OCS\Result(null, 404, $this->l->t('Share API is disabled')); } try { $share = $this->getShareById($id); } catch (ShareNotFound $e) { - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); } try { $share->getNode()->lock(ILockingProvider::LOCK_SHARED); } catch (LockedException $e) { - return new \OC_OCS_Result(null, 404, 'could not delete share'); + return new \OC\OCS\Result(null, 404, 'could not delete share'); } if (!$this->canAccessShare($share)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Could not delete share')); + return new \OC\OCS\Result(null, 404, $this->l->t('Could not delete share')); } $this->shareManager->deleteShare($share); $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(); + return new \OC\OCS\Result(); } /** - * @return \OC_OCS_Result + * @return \OC\OCS\Result */ public function createShare() { $share = $this->shareManager->newShare(); if (!$this->shareManager->shareApiEnabled()) { - return new \OC_OCS_Result(null, 404, $this->l->t('Share API is disabled')); + return new \OC\OCS\Result(null, 404, $this->l->t('Share API is disabled')); } // Verify path $path = $this->request->getParam('path', null); if ($path === null) { - return new \OC_OCS_Result(null, 404, $this->l->t('Please specify a file or folder path')); + return new \OC\OCS\Result(null, 404, $this->l->t('Please specify a file or folder path')); } $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); try { $path = $userFolder->get($path); } catch (NotFoundException $e) { - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong path, file/folder doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong path, file/folder doesn\'t exist')); } $share->setNode($path); @@ -262,7 +262,7 @@ public function createShare() { try { $share->getNode()->lock(ILockingProvider::LOCK_SHARED); } catch (LockedException $e) { - return new \OC_OCS_Result(null, 404, 'Could not create share'); + return new \OC\OCS\Result(null, 404, 'Could not create share'); } // Parse permissions (if available) @@ -275,7 +275,7 @@ public function createShare() { if ($permissions < 0 || $permissions > \OCP\Constants::PERMISSION_ALL) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, 'invalid permissions'); + return new \OC\OCS\Result(null, 404, 'invalid permissions'); } // Shares always require read permissions @@ -303,20 +303,20 @@ public function createShare() { // Valid user is required to share if ($shareWith === null || !$this->userManager->userExists($shareWith)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Please specify a valid user')); + return new \OC\OCS\Result(null, 404, $this->l->t('Please specify a valid user')); } $share->setSharedWith($shareWith); $share->setPermissions($permissions); } else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { if (!$this->shareManager->allowGroupSharing()) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Group sharing is disabled by the administrator')); + return new \OC\OCS\Result(null, 404, $this->l->t('Group sharing is disabled by the administrator')); } // Valid group is required to share if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Please specify a valid group')); + return new \OC\OCS\Result(null, 404, $this->l->t('Please specify a valid group')); } $share->setSharedWith($shareWith); $share->setPermissions($permissions); @@ -324,7 +324,7 @@ public function createShare() { //Can we even share links? if (!$this->shareManager->shareApiAllowLinks()) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Public link sharing is disabled by the administrator')); + return new \OC\OCS\Result(null, 404, $this->l->t('Public link sharing is disabled by the administrator')); } /* @@ -334,7 +334,7 @@ public function createShare() { $existingShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, false, 1, 0); if (!empty($existingShares)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result($this->formatShare($existingShares[0])); + return new \OC\OCS\Result($this->formatShare($existingShares[0])); } $publicUpload = $this->request->getParam('publicUpload', null); @@ -342,13 +342,13 @@ public function createShare() { // Check if public upload is allowed if (!$this->shareManager->shareApiLinkAllowPublicUpload()) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 403, $this->l->t('Public upload disabled by the administrator')); + return new \OC\OCS\Result(null, 403, $this->l->t('Public upload disabled by the administrator')); } // Public upload can only be set for folders if ($path instanceof \OCP\Files\File) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Public upload is only possible for publicly shared folders')); + return new \OC\OCS\Result(null, 404, $this->l->t('Public upload is only possible for publicly shared folders')); } $share->setPermissions( @@ -377,21 +377,21 @@ public function createShare() { $share->setExpirationDate($expireDate); } catch (\Exception $e) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Invalid date, date format must be YYYY-MM-DD')); + return new \OC\OCS\Result(null, 404, $this->l->t('Invalid date, date format must be YYYY-MM-DD')); } } } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 403, $this->l->t('Sharing %s failed because the back end does not allow shares from type %s', [$path->getPath(), $shareType])); + return new \OC\OCS\Result(null, 403, $this->l->t('Sharing %s failed because the back end does not allow shares from type %s', [$path->getPath(), $shareType])); } $share->setSharedWith($shareWith); $share->setPermissions($permissions); } else { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, $this->l->t('Unknown share type')); + return new \OC\OCS\Result(null, 400, $this->l->t('Unknown share type')); } $share->setShareType($shareType); @@ -402,24 +402,25 @@ public function createShare() { } catch (GenericShareException $e) { $code = $e->getCode() === 0 ? 403 : $e->getCode(); $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, $code, $e->getHint()); + return new \OC\OCS\Result(null, $code, $e->getHint()); }catch (\Exception $e) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 403, $e->getMessage()); + return new \OC\OCS\Result(null, 403, $e->getMessage()); } $output = $this->formatShare($share); $share->getNode()->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result($output); + return new \OC\OCS\Result($output); } /** * @param \OCP\Files\File|\OCP\Files\Folder $node - * @return \OC_OCS_Result + * @param boolean $includeTags + * @return \OC\OCS\Result */ - private function getSharedWithMe($node = null) { + private function getSharedWithMe($node = null, $includeTags) { $userShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, -1, 0); $groupShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0); @@ -436,16 +437,20 @@ private function getSharedWithMe($node = null) { } } - return new \OC_OCS_Result($formatted); + if ($includeTags) { + $formatted = \OCA\Files\Helper::populateTags($formatted, 'file_source'); + } + + return new \OC\OCS\Result($formatted); } /** * @param \OCP\Files\Folder $folder - * @return \OC_OCS_Result + * @return \OC\OCS\Result */ private function getSharesInDir($folder) { if (!($folder instanceof \OCP\Files\Folder)) { - return new \OC_OCS_Result(null, 400, $this->l->t('Not a directory')); + return new \OC\OCS\Result(null, 400, $this->l->t('Not a directory')); } $nodes = $folder->getDirectoryListing(); @@ -469,7 +474,7 @@ private function getSharesInDir($folder) { } } - return new \OC_OCS_Result($formatted); + return new \OC\OCS\Result($formatted); } /** @@ -481,11 +486,11 @@ private function getSharesInDir($folder) { * - Get shares for a specific path (?path=...) * - Get all shares in a folder (?subfiles=true&path=..) * - * @return \OC_OCS_Result + * @return \OC\OCS\Result */ public function getShares() { if (!$this->shareManager->shareApiEnabled()) { - return new \OC_OCS_Result(); + return new \OC\OCS\Result(); } $sharedWithMe = $this->request->getParam('shared_with_me', null); @@ -493,20 +498,22 @@ public function getShares() { $subfiles = $this->request->getParam('subfiles'); $path = $this->request->getParam('path', null); + $includeTags = $this->request->getParam('include_tags', false); + if ($path !== null) { $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); try { $path = $userFolder->get($path); $path->lock(ILockingProvider::LOCK_SHARED); } catch (\OCP\Files\NotFoundException $e) { - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong path, file/folder doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong path, file/folder doesn\'t exist')); } catch (LockedException $e) { - return new \OC_OCS_Result(null, 404, $this->l->t('Could not lock path')); + return new \OC\OCS\Result(null, 404, $this->l->t('Could not lock path')); } } if ($sharedWithMe === 'true') { - $result = $this->getSharedWithMe($path); + $result = $this->getSharedWithMe($path, $includeTags); if ($path !== null) { $path->unlock(ILockingProvider::LOCK_SHARED); } @@ -547,33 +554,37 @@ public function getShares() { } } + if ($includeTags) { + $formatted = \OCA\Files\Helper::populateTags($formatted, 'file_source'); + } + if ($path !== null) { $path->unlock(ILockingProvider::LOCK_SHARED); } - return new \OC_OCS_Result($formatted); + return new \OC\OCS\Result($formatted); } /** * @param int $id - * @return \OC_OCS_Result + * @return \OC\OCS\Result */ public function updateShare($id) { if (!$this->shareManager->shareApiEnabled()) { - return new \OC_OCS_Result(null, 404, $this->l->t('Share API is disabled')); + return new \OC\OCS\Result(null, 404, $this->l->t('Share API is disabled')); } try { $share = $this->getShareById($id); } catch (ShareNotFound $e) { - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); } $share->getNode()->lock(\OCP\Lock\ILockingProvider::LOCK_SHARED); if (!$this->canAccessShare($share)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); + return new \OC\OCS\Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); } $permissions = $this->request->getParam('permissions', null); @@ -587,7 +598,7 @@ public function updateShare($id) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { if ($permissions === null && $password === null && $publicUpload === null && $expireDate === null) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, 'Wrong or no update parameter given'); + return new \OC\OCS\Result(null, 400, 'Wrong or no update parameter given'); } $newPermissions = null; @@ -609,7 +620,7 @@ public function updateShare($id) { $newPermissions !== (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) ) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, $this->l->t('Can\'t change permissions for public share links')); + return new \OC\OCS\Result(null, 400, $this->l->t('Can\'t change permissions for public share links')); } if ( @@ -620,12 +631,12 @@ public function updateShare($id) { ) { if (!$this->shareManager->shareApiLinkAllowPublicUpload()) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 403, $this->l->t('Public upload disabled by the administrator')); + return new \OC\OCS\Result(null, 403, $this->l->t('Public upload disabled by the administrator')); } if (!($share->getNode() instanceof \OCP\Files\Folder)) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, $this->l->t('Public upload is only possible for publicly shared folders')); + return new \OC\OCS\Result(null, 400, $this->l->t('Public upload is only possible for publicly shared folders')); } // normalize to correct public upload permissions @@ -643,7 +654,7 @@ public function updateShare($id) { $expireDate = $this->parseDate($expireDate); } catch (\Exception $e) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, $e->getMessage()); + return new \OC\OCS\Result(null, 400, $e->getMessage()); } $share->setExpirationDate($expireDate); } @@ -658,7 +669,7 @@ public function updateShare($id) { // For other shares only permissions is valid. if ($permissions === null) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, $this->l->t('Wrong or no update parameter given')); + return new \OC\OCS\Result(null, 400, $this->l->t('Wrong or no update parameter given')); } else { $permissions = (int)$permissions; $share->setPermissions($permissions); @@ -678,7 +689,7 @@ public function updateShare($id) { if ($share->getPermissions() & ~$maxPermissions) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 404, $this->l->t('Cannot increase permissions')); + return new \OC\OCS\Result(null, 404, $this->l->t('Cannot increase permissions')); } } } @@ -688,12 +699,12 @@ public function updateShare($id) { $share = $this->shareManager->updateShare($share); } catch (\Exception $e) { $share->getNode()->unlock(ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result(null, 400, $e->getMessage()); + return new \OC\OCS\Result(null, 400, $e->getMessage()); } $share->getNode()->unlock(\OCP\Lock\ILockingProvider::LOCK_SHARED); - return new \OC_OCS_Result($this->formatShare($share)); + return new \OC\OCS\Result($this->formatShare($share)); } /** diff --git a/apps/files_sharing/tests/API/Share20OCSTest.php b/apps/files_sharing/tests/API/Share20OCSTest.php index 563ee08b5011..048f8e9c8372 100644 --- a/apps/files_sharing/tests/API/Share20OCSTest.php +++ b/apps/files_sharing/tests/API/Share20OCSTest.php @@ -138,7 +138,7 @@ public function testDeleteShareShareNotFound() { $this->shareManager->method('outgoingServer2ServerSharesAllowed')->willReturn(true); - $expected = new \OC_OCS_Result(null, 404, 'Wrong share ID, share doesn\'t exist'); + $expected = new \OC\OCS\Result(null, 404, 'Wrong share ID, share doesn\'t exist'); $this->assertEquals($expected, $this->ocs->deleteShare(42)); } @@ -165,7 +165,7 @@ public function testDeleteShare() { ->method('unlock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $expected = new \OC_OCS_Result(); + $expected = new \OC\OCS\Result(); $this->assertEquals($expected, $this->ocs->deleteShare(42)); } @@ -193,7 +193,7 @@ public function testDeleteShareLocked() { ->method('unlock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $expected = new \OC_OCS_Result(null, 404, 'could not delete share'); + $expected = new \OC\OCS\Result(null, 404, 'could not delete share'); $this->assertEquals($expected, $this->ocs->deleteShare(42)); } @@ -207,7 +207,7 @@ public function testGetGetShareNotExists() { ->with('ocinternal:42') ->will($this->throwException(new \OC\Share20\Exception\ShareNotFound())); - $expected = new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); + $expected = new \OC\OCS\Result(null, 404, 'wrong share ID, share doesn\'t exist.'); $this->assertEquals($expected, $this->ocs->getShare(42)); } */ @@ -471,7 +471,7 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) { ['group', $group], ])); - $expected = new \OC_OCS_Result([$result]); + $expected = new \OC\OCS\Result([$result]); $this->assertEquals($expected->getData(), $ocs->getShare($share->getId())->getData()); } @@ -487,7 +487,7 @@ public function testGetShareInvalidNode() { ->with('ocinternal:42') ->willReturn($share); - $expected = new \OC_OCS_Result(null, 404, 'Wrong share ID, share doesn\'t exist'); + $expected = new \OC\OCS\Result(null, 404, 'Wrong share ID, share doesn\'t exist'); $this->assertEquals($expected->getMeta(), $this->ocs->getShare(42)->getMeta()); } @@ -539,7 +539,7 @@ public function testCanAccessShare() { } public function testCreateShareNoPath() { - $expected = new \OC_OCS_Result(null, 404, 'Please specify a file or folder path'); + $expected = new \OC\OCS\Result(null, 404, 'Please specify a file or folder path'); $result = $this->ocs->createShare(); @@ -565,7 +565,7 @@ public function testCreateShareInvalidPath() { ->with('invalid-path') ->will($this->throwException(new \OCP\Files\NotFoundException())); - $expected = new \OC_OCS_Result(null, 404, 'Wrong path, file/folder doesn\'t exist'); + $expected = new \OC\OCS\Result(null, 404, 'Wrong path, file/folder doesn\'t exist'); $result = $this->ocs->createShare(); @@ -600,7 +600,7 @@ public function testCreateShareInvalidPermissions() { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $expected = new \OC_OCS_Result(null, 404, 'invalid permissions'); + $expected = new \OC\OCS\Result(null, 404, 'invalid permissions'); $result = $this->ocs->createShare(); @@ -641,7 +641,7 @@ public function testCreateShareUserNoShareWith() { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $expected = new \OC_OCS_Result(null, 404, 'Please specify a valid user'); + $expected = new \OC\OCS\Result(null, 404, 'Please specify a valid user'); $result = $this->ocs->createShare(); @@ -679,7 +679,7 @@ public function testCreateShareUserNoValidShareWith() { ->with('valid-path') ->willReturn($path); - $expected = new \OC_OCS_Result(null, 404, 'Please specify a valid user'); + $expected = new \OC\OCS\Result(null, 404, 'Please specify a valid user'); $path->expects($this->once()) ->method('lock') @@ -757,7 +757,7 @@ public function testCreateShareUser() { })) ->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(); + $expected = new \OC\OCS\Result(); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -795,7 +795,7 @@ public function testCreateShareGroupNoValidShareWith() { ->with('valid-path') ->willReturn($path); - $expected = new \OC_OCS_Result(null, 404, 'Please specify a valid user'); + $expected = new \OC\OCS\Result(null, 404, 'Please specify a valid user'); $path->expects($this->once()) ->method('lock') @@ -873,7 +873,7 @@ public function testCreateShareGroup() { })) ->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(); + $expected = new \OC\OCS\Result(); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -916,7 +916,7 @@ public function testCreateShareGroupNotAllowed() { ->method('allowGroupSharing') ->willReturn(false); - $expected = new \OC_OCS_Result(null, 404, 'Group sharing is disabled by the administrator'); + $expected = new \OC\OCS\Result(null, 404, 'Group sharing is disabled by the administrator'); $result = $this->ocs->createShare(); @@ -943,7 +943,7 @@ public function testCreateShareLinkNoLinksAllowed() { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); - $expected = new \OC_OCS_Result(null, 404, 'Public link sharing is disabled by the administrator'); + $expected = new \OC\OCS\Result(null, 404, 'Public link sharing is disabled by the administrator'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -971,7 +971,7 @@ public function testCreateShareLinkNoPublicUpload() { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); - $expected = new \OC_OCS_Result(null, 403, 'Public upload disabled by the administrator'); + $expected = new \OC\OCS\Result(null, 403, 'Public upload disabled by the administrator'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1000,7 +1000,7 @@ public function testCreateShareLinkPublicUploadFile() { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 404, 'Public upload is only possible for publicly shared folders'); + $expected = new \OC\OCS\Result(null, 404, 'Public upload is only possible for publicly shared folders'); $result = $this->ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1044,7 +1044,7 @@ public function testCreateShareLinkPublicUploadFolder() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1088,7 +1088,7 @@ public function testCreateShareLinkPassword() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1135,7 +1135,7 @@ public function testCreateShareValidExpireDate() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1168,7 +1168,7 @@ public function testCreateShareInvalidExpireDate() { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 404, 'Invalid date, date format must be YYYY-MM-DD'); + $expected = new \OC\OCS\Result(null, 404, 'Invalid date, date format must be YYYY-MM-DD'); $result = $ocs->createShare(); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1247,7 +1247,7 @@ public function testUpdateShareCantAccess() { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); - $expected = new \OC_OCS_Result(null, 404, 'Wrong share ID, share doesn\'t exist'); + $expected = new \OC\OCS\Result(null, 404, 'Wrong share ID, share doesn\'t exist'); $result = $this->ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1268,7 +1268,7 @@ public function testUpdateNoParametersLink() { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); - $expected = new \OC_OCS_Result(null, 400, 'Wrong or no update parameter given'); + $expected = new \OC\OCS\Result(null, 400, 'Wrong or no update parameter given'); $result = $this->ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1289,7 +1289,7 @@ public function testUpdateNoParametersOther() { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); - $expected = new \OC_OCS_Result(null, 400, 'Wrong or no update parameter given'); + $expected = new \OC\OCS\Result(null, 400, 'Wrong or no update parameter given'); $result = $this->ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1334,7 +1334,7 @@ public function testUpdateLinkShareClear() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1374,7 +1374,7 @@ public function testUpdateLinkShareSet() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1412,7 +1412,7 @@ public function testUpdateLinkShareEnablePublicUpload($params) { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1441,7 +1441,7 @@ public function testUpdateLinkShareInvalidDate() { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 400, 'Invalid date. Format must be YYYY-MM-DD'); + $expected = new \OC\OCS\Result(null, 400, 'Invalid date. Format must be YYYY-MM-DD'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1489,7 +1489,7 @@ public function testUpdateLinkSharePublicUploadNotAllowed($params) { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(false); - $expected = new \OC_OCS_Result(null, 403, 'Public upload disabled by the administrator'); + $expected = new \OC\OCS\Result(null, 403, 'Public upload disabled by the administrator'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1518,7 +1518,7 @@ public function testUpdateLinkSharePublicUploadOnFile() { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 400, 'Public upload is only possible for publicly shared folders'); + $expected = new \OC\OCS\Result(null, 400, 'Public upload is only possible for publicly shared folders'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1564,7 +1564,7 @@ public function testUpdateLinkSharePasswordDoesNotChangeOther() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1610,7 +1610,7 @@ public function testUpdateLinkShareExpireDateDoesNotChangeOther() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1650,7 +1650,7 @@ public function testUpdateLinkSharePublicUploadDoesNotChangeOther() { }) )->will($this->returnArgument(0)); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1692,7 +1692,7 @@ public function testUpdateLinkSharePermissions() { $this->shareManager->method('getSharedWith')->willReturn([]); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1724,7 +1724,7 @@ public function testUpdateLinkShareInvalidPermissions() { $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $expected = new \OC_OCS_Result(null, 400, 'Can\'t change permissions for public share links'); + $expected = new \OC\OCS\Result(null, 400, 'Can\'t change permissions for public share links'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1759,7 +1759,7 @@ public function testUpdateOtherPermissions() { $this->shareManager->method('getSharedWith')->willReturn([]); - $expected = new \OC_OCS_Result(null); + $expected = new \OC\OCS\Result(null); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1812,7 +1812,7 @@ public function testUpdateShareCannotIncreasePermissions() { $this->shareManager->expects($this->never())->method('updateShare'); - $expected = new \OC_OCS_Result(null, 404, 'Cannot increase permissions'); + $expected = new \OC\OCS\Result(null, 404, 'Cannot increase permissions'); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -1868,7 +1868,7 @@ public function testUpdateShareCanIncreasePermissionsIfOwner() { ->with($share) ->willReturn($share); - $expected = new \OC_OCS_Result(); + $expected = new \OC\OCS\Result(); $result = $ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); @@ -2227,7 +2227,7 @@ public function getOcsDisabledAPI() { public function testGetShareApiDisabled() { $ocs = $this->getOcsDisabledAPI(); - $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled'); + $expected = new \OC\OCS\Result(null, 404, 'Share API is disabled'); $result = $ocs->getShare('my:id'); $this->assertEquals($expected, $result); @@ -2236,7 +2236,7 @@ public function testGetShareApiDisabled() { public function testDeleteShareApiDisabled() { $ocs = $this->getOcsDisabledAPI(); - $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled'); + $expected = new \OC\OCS\Result(null, 404, 'Share API is disabled'); $result = $ocs->deleteShare('my:id'); $this->assertEquals($expected, $result); @@ -2246,7 +2246,7 @@ public function testDeleteShareApiDisabled() { public function testCreateShareApiDisabled() { $ocs = $this->getOcsDisabledAPI(); - $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled'); + $expected = new \OC\OCS\Result(null, 404, 'Share API is disabled'); $result = $ocs->createShare(); $this->assertEquals($expected, $result); @@ -2255,7 +2255,7 @@ public function testCreateShareApiDisabled() { public function testGetSharesApiDisabled() { $ocs = $this->getOcsDisabledAPI(); - $expected = new \OC_OCS_Result(); + $expected = new \OC\OCS\Result(); $result = $ocs->getShares(); $this->assertEquals($expected, $result); @@ -2264,7 +2264,7 @@ public function testGetSharesApiDisabled() { public function testUpdateShareApiDisabled() { $ocs = $this->getOcsDisabledAPI(); - $expected = new \OC_OCS_Result(null, 404, 'Share API is disabled'); + $expected = new \OC\OCS\Result(null, 404, 'Share API is disabled'); $result = $ocs->updateShare('my:id'); $this->assertEquals($expected, $result); diff --git a/apps/files_sharing/tests/js/sharedfilelistSpec.js b/apps/files_sharing/tests/js/sharedfilelistSpec.js index f177b61c78a0..3efbb8fcea3f 100644 --- a/apps/files_sharing/tests/js/sharedfilelistSpec.js +++ b/apps/files_sharing/tests/js/sharedfilelistSpec.js @@ -48,6 +48,8 @@ describe('OCA.Sharing.FileList tests', function() { '
Empty content message
' + '' ); + + OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin); }); afterEach(function() { testFiles = undefined; @@ -93,6 +95,7 @@ describe('OCA.Sharing.FileList tests', function() { share_type: OC.Share.SHARE_TYPE_USER, share_with: 'user1', share_with_displayname: 'User One', + tags: [OC.TAG_FAVORITE], mimetype: 'text/plain', uid_owner: 'user2', displayname_owner: 'User Two' @@ -133,12 +136,12 @@ describe('OCA.Sharing.FileList tests', function() { expect(fakeServer.requests.length).toEqual(2); expect(fakeServer.requests[0].url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=true' + 'shares?format=json&shared_with_me=true&include_tags=true' ); expect(fakeServer.requests[1].url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'remote_shares?format=json' + 'remote_shares?format=json&include_tags=true' ); fakeServer.requests[0].respond( @@ -150,7 +153,7 @@ describe('OCA.Sharing.FileList tests', function() { fakeServer.requests[1].respond( 200, { 'Content-Type': 'application/json' }, - JSON.stringify(ocsResponseRemote) + JSON.stringify(ocsResponseRemote) ); var $rows = fileList.$el.find('tbody tr'); @@ -167,6 +170,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('11111000'); expect($tr.attr('data-share-owner')).toEqual('User Two'); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt' @@ -185,6 +190,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('22222000'); expect($tr.attr('data-share-owner')).toEqual('user3@foo.bar/'); expect($tr.attr('data-share-id')).toEqual('8'); + expect($tr.attr('data-favorite')).not.toBeDefined(); + expect($tr.attr('data-tags')).toEqual(''); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/b.txt' @@ -209,11 +216,11 @@ describe('OCA.Sharing.FileList tests', function() { expect(fakeServer.requests.length).toEqual(2); expect(fakeServer.requests[0].url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=true' + 'shares?format=json&shared_with_me=true&include_tags=true' ); expect(fakeServer.requests[1].url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'remote_shares?format=json' + 'remote_shares?format=json&include_tags=true' ); fakeServer.requests[0].respond( @@ -241,6 +248,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('11111000'); expect($tr.attr('data-share-owner')).toEqual('User Two'); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/index.php/apps/files' + @@ -260,6 +269,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('22222000'); expect($tr.attr('data-share-owner')).toEqual('user3@foo.bar/'); expect($tr.attr('data-share-id')).toEqual('8'); + expect($tr.attr('data-favorite')).not.toBeDefined(); + expect($tr.attr('data-tags')).toEqual(''); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/index.php/apps/files' + @@ -301,6 +312,7 @@ describe('OCA.Sharing.FileList tests', function() { share_type: OC.Share.SHARE_TYPE_USER, share_with: 'user2', share_with_displayname: 'User Two', + tags: [OC.TAG_FAVORITE], mimetype: 'text/plain', uid_owner: 'user1', displayname_owner: 'User One' @@ -315,7 +327,7 @@ describe('OCA.Sharing.FileList tests', function() { request = fakeServer.requests[0]; expect(request.url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=false' + 'shares?format=json&shared_with_me=false&include_tags=true' ); fakeServer.requests[0].respond( @@ -337,6 +349,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('11111000'); expect($tr.attr('data-share-owner')).not.toBeDefined(); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt' @@ -355,7 +369,7 @@ describe('OCA.Sharing.FileList tests', function() { request = fakeServer.requests[0]; expect(request.url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=false' + 'shares?format=json&shared_with_me=false&include_tags=true' ); fakeServer.requests[0].respond( @@ -377,6 +391,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('11111000'); expect($tr.attr('data-share-owner')).not.toBeDefined(); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/index.php/apps/files' + @@ -400,13 +416,14 @@ describe('OCA.Sharing.FileList tests', function() { token: 'abc', mimetype: 'text/plain', uid_owner: 'user1', - displayname_owner: 'User One' + displayname_owner: 'User One', + tags: [OC.TAG_FAVORITE] }; expect(fakeServer.requests.length).toEqual(1); request = fakeServer.requests[0]; expect(request.url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=false' + 'shares?format=json&shared_with_me=false&include_tags=true' ); fakeServer.requests[0].respond( @@ -428,6 +445,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('11111000'); expect($tr.attr('data-share-owner')).not.toBeDefined(); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt' ); @@ -451,7 +470,8 @@ describe('OCA.Sharing.FileList tests', function() { token: 'abc', mimetype: 'text/plain', uid_owner: 'user1', - displayname_owner: 'User One' + displayname_owner: 'User One', + tags: [OC.TAG_FAVORITE], }); // another share of the same file ocsResponse.ocs.data.push({ @@ -473,7 +493,7 @@ describe('OCA.Sharing.FileList tests', function() { request = fakeServer.requests[0]; expect(request.url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=false' + 'shares?format=json&shared_with_me=false&include_tags=true' ); fakeServer.requests[0].respond( @@ -496,6 +516,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-mtime')).toEqual('22222000'); expect($tr.attr('data-share-owner')).not.toBeDefined(); expect($tr.attr('data-share-id')).toEqual('7,8,9'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt' ); @@ -540,7 +562,8 @@ describe('OCA.Sharing.FileList tests', function() { token: 'abc', mimetype: 'text/plain', uid_owner: 'user1', - displayname_owner: 'User One' + displayname_owner: 'User One', + tags: [OC.TAG_FAVORITE] },{ id: 8, item_type: 'file', @@ -577,13 +600,14 @@ describe('OCA.Sharing.FileList tests', function() { share_with_displayname: 'User Two', mimetype: 'text/plain', uid_owner: 'user1', - displayname_owner: 'User One' + displayname_owner: 'User One', + tags: [OC.TAG_FAVORITE] }); expect(fakeServer.requests.length).toEqual(1); request = fakeServer.requests[0]; expect(request.url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=false' + 'shares?format=json&shared_with_me=false&include_tags=true' ); fakeServer.requests[0].respond( @@ -607,6 +631,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-share-recipients')).not.toBeDefined(); expect($tr.attr('data-share-owner')).not.toBeDefined(); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt' ); @@ -620,6 +646,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-id')).toEqual('50'); expect($tr.attr('data-file')).toEqual('local name2.txt'); expect($tr.attr('data-expiration')).not.toEqual('0'); + expect($tr.attr('data-favorite')).not.toBeDefined(); + expect($tr.attr('data-tags')).toEqual(''); expect($tr.find('td:last-child span').text()).toEqual('in a day'); }); it('does not show virtual token recipient as recipient when password was set', function() { @@ -632,7 +660,7 @@ describe('OCA.Sharing.FileList tests', function() { request = fakeServer.requests[0]; expect(request.url).toEqual( OC.linkToOCS('apps/files_sharing/api/v1') + - 'shares?format=json&shared_with_me=false' + 'shares?format=json&shared_with_me=false&include_tags=true' ); fakeServer.requests[0].respond( @@ -656,6 +684,8 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.attr('data-share-recipients')).not.toBeDefined(); expect($tr.attr('data-share-owner')).not.toBeDefined(); expect($tr.attr('data-share-id')).toEqual('7'); + expect($tr.attr('data-favorite')).toEqual('true'); + expect($tr.attr('data-tags')).toEqual(OC.TAG_FAVORITE); expect($tr.find('a.name').attr('href')).toEqual( OC.webroot + '/remote.php/webdav/local%20path/local%20name.txt');