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

Fixes for tasks

This commit is contained in:
David Bomba 2024-04-12 09:06:34 +10:00
parent e35d12d0b9
commit 76cdc52331
2 changed files with 44 additions and 1 deletions

View File

@ -80,7 +80,6 @@ class UpdateInvoiceRequest extends Request
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date', 'before:due_date'];
$rules['due_date'] = ['bail', 'sometimes', 'nullable', 'after:partial_due_date', Rule::requiredIf(fn () => strlen($this->partial_due_date) > 1), 'date'];
return $rules;
}

View File

@ -104,6 +104,50 @@ class TaskApiTest extends TestCase
}
}
public function testUserFilters()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->getJson("/api/v1/tasks")->assertStatus(200);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->getJson("/api/v1/tasks?user_id={$this->user->hashed_id}");
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals($this->user->hashed_id, $arr['data'][0]['user_id']);
$this->assertCount(1, $arr['data']);
$t = Task::factory()->create([
'client_id' => $this->client->id,
'user_id' => $this->user->id,
'assigned_user_id' => $this->user->id,
'company_id' => $this->company->id,
'description' => 'Test Task',
'time_log' => '[[1681165417,1681165432,"sumtin",true],[1681165446,0]]',
]);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->getJson("/api/v1/tasks?assigned_user={$this->user->hashed_id}");
$response->assertStatus(200);
$arr = $response->json();
$this->assertEquals($this->user->hashed_id, $arr['data'][0]['user_id']);
$this->assertEquals($this->user->hashed_id, $arr['data'][0]['assigned_user_id']);
$this->assertCount(1, $arr['data']);
}
public function testEmptyTimeLogArray()
{