Task Status Order tests

This commit is contained in:
David Bomba 2025-01-03 21:27:14 +11:00
parent fd4ffe4195
commit 24ed1922fc
3 changed files with 28 additions and 7 deletions

View File

@ -274,14 +274,12 @@ class TaskController extends BaseController
}
$old_task_status_order = $task->status_order;
// $old_task = json_decode(json_encode($task));
$task = $this->task_repo->save($request->all(), $task);
$task = $this->task_repo->triggeredActions($request, $task);
if ($task->status_order != $old_task_status_order) {
// if ($task->status_order != $old_task->status_order) {
if (is_null($task->status_order) || $task->status_order != $old_task_status_order) {
$this->task_repo->sortStatuses($task);
}

View File

@ -329,7 +329,7 @@ class TaskRepository extends BaseRepository
$task = $this->stop($task);
}
return $task;
return $task->fresh();
}
private function init(Task $task): self

View File

@ -11,13 +11,14 @@
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Task;
use App\Models\TaskStatus;
use Tests\MockAccountData;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
*
@ -44,6 +45,28 @@ class TaskStatusApiTest extends TestCase
Model::reguard();
}
public function testTaskStatusProperty()
{
$t = Task::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
]);
$this->assertNull($t->status_order);
$update = [
'description' => 'newdescription'
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/tasks/'.$t->hashed_id, $update);
$response->assertStatus(200);
}
public function testSorting()
{
TaskStatus::query()->where('company_id', $this->company->id)->cursor()->each(function ($ts){