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:
parent
9db82b19a5
commit
8b3c1341e8
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user