You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use the Restify library, today I encountered a weird issue, maybe it could be due to me or a bug.
This is a snippet for my JobPolicy.php:
public function attachCategories(User $user, Job $job): bool
{
....(some checks on $job->project_id)
return true;
}
public function detachCategories(User $user, Job $job): bool
{
....(some checks on $job->project_id)
return true;
}
It happened when I test the attach and detach:
test('marketeer can detach category from job', function () {
logInWithProject($this->project->fresh());
$job = Job::factory()->create();
$category = Category::factory()->create();
postJson(JobRepository::route($job->id.'/attach/categories'), [
'categories' => [$category->id],
])->assertCreated();
postJson(JobRepository::route($job->id.'/detach/categories'), [
'categories' => [$category->id],
])->assertNoContent();
expect(JobCategory::all()->count())->toBe(0);
});
The problem I face is, the attach $job parameter is correct. but the detach $job parameter is an empty job model.
The get returns correctly the job, so I am not sure where the problem is, maybe it could be within restify.
Reproducing this error:
You can reproduce this by doing dd($job) or dd($job->toArray()) inside the detachCategories it will return empty job model or []. but in attach it will return the correct job.
The text was updated successfully, but these errors were encountered:
Hello!
We use the Restify library, today I encountered a weird issue, maybe it could be due to me or a bug.
This is a snippet for my JobPolicy.php:
It happened when I test the attach and detach:
The problem I face is, the attach
$job
parameter is correct. but the detach$job
parameter is an empty job model.I tried inside the test to debug:
The get returns correctly the job, so I am not sure where the problem is, maybe it could be within restify.
Reproducing this error:
You can reproduce this by doing dd($job) or dd($job->toArray()) inside the
detachCategories
it will return empty job model or []. but in attach it will return the correct job.The text was updated successfully, but these errors were encountered: