Add prefer_inner for group api
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
2ba31a0678
commit
bd6ccf030b
|
@ -6,8 +6,6 @@ use App\Group;
|
||||||
use App\Group\Resources\GroupResource;
|
use App\Group\Resources\GroupResource;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
use Inertia\Inertia;
|
|
||||||
use Inertia\Response;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class GroupApiIndexAction
|
class GroupApiIndexAction
|
||||||
|
|
|
@ -24,7 +24,7 @@ class GroupResource extends JsonResource
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->name,
|
'name' => $request->has('prefer_inner') && $this->inner_name ? $this->inner_name : $this->name,
|
||||||
'inner_name' => $this->inner_name,
|
'inner_name' => $this->inner_name,
|
||||||
'parent_id' => $this->parent_id,
|
'parent_id' => $this->parent_id,
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
|
|
@ -36,6 +36,17 @@ class IndexTest extends TestCase
|
||||||
->assertJsonPath('meta.links.bulkstore', route('group.bulkstore'));
|
->assertJsonPath('meta.links.bulkstore', route('group.bulkstore'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItPrefersInnerName(): void
|
||||||
|
{
|
||||||
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
|
|
||||||
|
$group = Group::factory()->create(['name' => 'Afff', 'inner_name' => 'Gruppe', 'level' => Level::REGION]);
|
||||||
|
|
||||||
|
$this->get('/api/group?prefer_inner')
|
||||||
|
->assertJsonPath('data.1.name', 'Gruppe')
|
||||||
|
->assertJsonPath('data.1.id', $group->id);
|
||||||
|
}
|
||||||
|
|
||||||
public function testItDisplaysGroupsForParent(): void
|
public function testItDisplaysGroupsForParent(): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
|
|
Loading…
Reference in New Issue