1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-01-01 17:42:46 +01:00

return error if new folder name is missing on update

Signed-off-by: Paul Tirk <paultirk@paultirk.com>
This commit is contained in:
Paul Tirk 2021-03-25 18:23:12 +01:00 committed by Sean Molenaar
parent 9db82b19a5
commit 8b3c1341e8
2 changed files with 9 additions and 1 deletions

View File

@ -72,6 +72,10 @@ class FolderApiV2Controller extends ApiController
*/
public function update($folderId, $name)
{
if (empty($name)) {
return $this->errorResponseV2('folder name is empty', 1, Http::STATUS_BAD_REQUEST);
}
$response = null;
try {
$response = $this->folderService->rename($this->getUserId(), $folderId, $name);

View File

@ -191,13 +191,17 @@ class FolderApiV2ControllerTest extends TestCase
public function testUpdateInvalidFolderName()
{
$msg = 'folder name is empty';
$code = 1;
$folderId = 23;
$folderName = '';
$response = $this->folderAPI->update($folderId, $folderName);
$data = $response->getData();
$this->assertEquals($this->msg, $data['error']['message']);
$this->assertEquals($msg, $data['error']['message']);
$this->assertEquals($code, $data['error']['code']);
$this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
}
}