Skip to content

Commit 585c98e

Browse files
committed
code rabbit
1 parent de36957 commit 585c98e

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/Http/Response.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ protected function buildGatesForModel(Model|string $model, Resource $resource, a
5252
}
5353
}
5454
} else {
55-
// TODO: put the good anchor to link to the new method (link in the string)
5655
trigger_deprecation('lomkit/laravel-rest-api', '2.17.0', 'In Laravel Rest Api 3 it won\'t be possible to use the old gate schema, please upgrade as quickly as possible. See: https://laravel-rest-api.lomkit.com/digging-deeper/gates#policy-message-in-gates');
5756
foreach ($gates as $gate) {
5857
if (isset($nameMap[$gate])) {

tests/Feature/Controllers/AutomaticGatingTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,65 @@ public function test_searching_automatic_gated_resource_and_custom_message(): vo
122122
);
123123
}
124124

125+
public function test_searching_automatic_gated_resource_with_allowed_gates_and_custom_message(): void
126+
{
127+
$model = ModelFactory::new()
128+
->create();
129+
130+
Gate::policy(Model::class, GreenPolicy::class);
131+
132+
config(['rest.gates.message.enabled' => true]);
133+
134+
$response = $this->post(
135+
'/api/automatic-gating/search',
136+
[
137+
'search' => [
138+
'gates' => ['create', 'view', 'update', 'delete', 'forceDelete', 'restore'],
139+
],
140+
],
141+
['Accept' => 'application/json']
142+
);
143+
144+
$this->assertResourcePaginated(
145+
$response,
146+
[$model],
147+
new AutomaticGatingResource(),
148+
[
149+
[
150+
'gates' => [
151+
'authorized_to_view' => [
152+
'allowed' => true,
153+
'message' => null,
154+
],
155+
'authorized_to_update' => [
156+
'allowed' => true,
157+
'message' => null,
158+
],
159+
'authorized_to_delete' => [
160+
'allowed' => true,
161+
'message' => null,
162+
],
163+
'authorized_to_restore' => [
164+
'allowed' => true,
165+
'message' => null,
166+
],
167+
'authorized_to_force_delete' => [
168+
'allowed' => true,
169+
'message' => null,
170+
],
171+
],
172+
],
173+
]
174+
);
175+
$response->assertJsonPath(
176+
'meta.gates.authorized_to_create',
177+
[
178+
'allowed' => true,
179+
'message' => null,
180+
]
181+
);
182+
}
183+
125184
public function test_searching_automatic_gated_resource_with_global_config_disabled(): void
126185
{
127186
$model = ModelFactory::new()

0 commit comments

Comments
 (0)