diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 81109c35..32fb3a83 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -57,7 +57,7 @@ class MemberController extends Controller session()->put('menu', 'member'); session()->put('title', 'Mitglied erstellen'); - $activities = Activity::with('subactivities')->get(); + $activities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get(); return \Inertia::render('member/VForm', [ 'activities' => $activities->pluck('name', 'id'), @@ -90,7 +90,7 @@ class MemberController extends Controller session()->put('menu', 'member'); session()->put('title', "Mitglied {$member->firstname} {$member->lastname} bearbeiten"); - $activities = Activity::with('subactivities')->get(); + $activities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get(); return \Inertia::render('member/VForm', [ 'activities' => $activities->pluck('name', 'id'), diff --git a/tests/Feature/Member/CreateTest.php b/tests/Feature/Member/CreateTest.php index e6df1cfc..c0f4b520 100644 --- a/tests/Feature/Member/CreateTest.php +++ b/tests/Feature/Member/CreateTest.php @@ -12,12 +12,18 @@ class CreateTest extends TestCase { use DatabaseTransactions; - public function testItDisplaysCreatePage(): void + public function setUp(): void { + parent::setUp(); + $this->withoutExceptionHandling(); $this->login()->loginNami(); Country::factory()->create(['name' => 'Deutschland']); - $activity = Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create(); + } + + public function testItDisplaysCreatePage(): void + { + $activity = Activity::factory()->inNami(5)->hasAttached(Subactivity::factory()->inNami(23)->name('Biber'))->name('€ Mitglied')->create(); $subactivity = $activity->subactivities->first(); $response = $this->get(route('member.create')); @@ -26,4 +32,15 @@ class CreateTest extends TestCase $this->assertInertiaHas('€ Mitglied', $response, "activities.{$activity->id}"); $this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'billKinds.0'); } + + + public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void + { + Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create(); + + $response = $this->get(route('member.create')); + + $this->assertCount(0, $this->inertia($response, 'subactivities')); + $this->assertCount(0, $this->inertia($response, 'activities')); + } } diff --git a/tests/Feature/Member/EditTest.php b/tests/Feature/Member/EditTest.php index fb48b263..3004ae2a 100644 --- a/tests/Feature/Member/EditTest.php +++ b/tests/Feature/Member/EditTest.php @@ -17,7 +17,7 @@ class EditTest extends TestCase $this->withoutExceptionHandling(); $this->login()->loginNami(); $member = Member::factory()->defaults()->create(['firstname' => 'Max']); - $activity = Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create(); + $activity = Activity::factory()->inNami(66)->hasAttached(Subactivity::factory()->inNami(56)->name('Biber'))->name('€ Mitglied')->create(); $subactivity = $activity->subactivities->first(); $response = $this->get(route('member.edit', ['member' => $member]));