1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Reset task statuses on delete/archive

This commit is contained in:
= 2021-04-18 19:50:06 +10:00
parent 6eaff79544
commit 3cfabd88d7
4 changed files with 51 additions and 2 deletions

View File

@ -68,7 +68,7 @@ class Kernel extends ConsoleKernel
}
if(config('queue.default') && Ninja::isSelfHost()) {
if(config('queue.default') == 'database' && Ninja::isSelfHost()) {
$schedule->command('queue:work')->everyMinute()->withoutOverlapping();
$schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping();
}

View File

@ -8,6 +8,7 @@ use App\Http\Requests\TaskStatus\DestroyTaskStatusRequest;
use App\Http\Requests\TaskStatus\ShowTaskStatusRequest;
use App\Http\Requests\TaskStatus\StoreTaskStatusRequest;
use App\Http\Requests\TaskStatus\UpdateTaskStatusRequest;
use App\Models\Task;
use App\Models\TaskStatus;
use App\Repositories\TaskStatusRepository;
use App\Transformers\TaskStatusTransformer;
@ -398,8 +399,9 @@ class TaskStatusController extends BaseController
*/
public function destroy(DestroyTaskStatusRequest $request, TaskStatus $task_status)
{
$task_status->delete();
$this->task_status_repo->delete($task_status);
return $this->itemResponse($task_status->fresh());
}

View File

@ -11,9 +11,39 @@
namespace App\Repositories;
use App\Models\Task;
/**
* Class for task status repository.
*/
class TaskStatusRepository extends BaseRepository
{
public function delete($task_status)
{
Task::where('status_id', $task_status->id)
->where('company_id', $task_status->company_id)
->update(['status_id' => null]);
parent::delete($task_status);
return $task_status;
}
public function archive($task_status)
{
Task::where('status_id', $task_status->id)
->where('company_id', $task_status->company_id)
->update(['status_id' => null]);
parent::archive($task_status);
return $task_status;
}
}

View File

@ -122,6 +122,23 @@ class TaskStatusApiTest extends TestCase
$this->assertEquals(0, $arr['data'][0]['archived_at']);
}
public function testTaskStatusDeletedFromDELETEROute()
{
$data = [
'ids' => [$this->encodePrimaryKey($this->task_status->id)],
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->delete('/api/v1/task_statuses/'.$this->encodePrimaryKey($this->task_status->id));
$arr = $response->json();
$this->assertTrue($arr['data']['is_deleted']);
}
public function testTaskStatusDeleted()
{
$data = [