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:
parent
6eaff79544
commit
3cfabd88d7
@ -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();
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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 = [
|
||||
|
Loading…
Reference in New Issue
Block a user