Fixed: Show only active memberships in member index
continuous-integration/drone/push Build is failing Details

This commit is contained in:
philipp lang 2023-03-22 23:43:09 +01:00
parent 38d434aef8
commit 85a3abcc82
2 changed files with 15 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class MemberView
return [
'data' => MemberResource::collection(Member::search($filter->search)->query(fn ($q) => $q->select('*')
->withFilter($filter)
->with('payments.subscription')->with('memberships')->with('courses')->with('subscription')->with('leaderMemberships')->with('ageGroupMemberships')
->with('payments.subscription')->with(['memberships' => fn ($query) => $query->active()])->with('courses')->with('subscription')->with('leaderMemberships')->with('ageGroupMemberships')
->withPendingPayment()
->ordered()
)->paginate(15)),

View File

@ -127,6 +127,20 @@ class IndexTest extends TestCase
], $response, 'data.data.0.memberships.0');
}
public function testItDoesntShowEndedMemberships(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$group = Group::factory()->create();
$member = Member::factory()
->defaults()
->has(Membership::factory()->for($group)->in('€ Mitglied', 122, 'Wölfling', 234)->ended())
->create();
$response = $this->get('/member');
$this->assertCount(0, $this->inertia($response, 'data.data.0.memberships'));
}
public function testItReturnsPayments(): void
{
$this->withoutExceptionHandling()->login()->loginNami();