Fixed: Dont display local activities and subactivities on create
continuous-integration/drone/push Build is failing Details

This commit is contained in:
philipp lang 2023-02-17 01:57:06 +01:00
parent f106f2455a
commit 51ddefe30b
3 changed files with 22 additions and 5 deletions

View File

@ -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'),

View File

@ -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'));
}
}

View File

@ -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]));