Fixes for task scheduler

This commit is contained in:
David Bomba 2023-02-23 06:33:38 +11:00
parent 010f324b4c
commit 25d0640135
3 changed files with 18 additions and 17 deletions

View File

@ -22,6 +22,6 @@ class ShowSchedulerRequest extends Request
*/
public function authorize() : bool
{
return auth()->user()->can('view', $this->scheduler);
return auth()->user()->can('view', $this->task_scheduler);
}
}

View File

@ -23,7 +23,7 @@ class UpdateSchedulerRequest extends Request
*/
public function authorize(): bool
{
return auth()->user()->isAdmin();
return auth()->user()->isAdmin() && $this->task_scheduler->company_id == auth()->user()->company()->id;
}
public function rules(): array

View File

@ -54,6 +54,22 @@ class SchedulerTest extends TestCase
);
}
public function testSchedulerGet2()
{
$scheduler = SchedulerFactory::create($this->company->id, $this->user->id);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/task_schedulers/'.$this->encodePrimaryKey($scheduler->id));
$response->assertStatus(200);
}
public function testCustomDateRanges()
{
$data = [
@ -619,21 +635,6 @@ class SchedulerTest extends TestCase
}
// public function testSchedulerPut()
// {
// $data = [
// 'description' => $this->faker->firstName(),
// ];
// $response = $this->withHeaders([
// 'X-API-SECRET' => config('ninja.api_secret'),
// 'X-API-TOKEN' => $this->token,
// ])->put('/api/v1/task_schedulers/'.$this->encodePrimaryKey($this->task->id), $data);
// $response->assertStatus(200);
// }
// public function testSchedulerCantBeCreatedWithWrongData()
// {