From 45968d73499a1c71e8c5d24908aee9c9e3baa5a0 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 29 Apr 2023 21:20:04 +0200 Subject: [PATCH] Fixed: Show only active memberships in testers block --- app/Member/Membership.php | 2 +- tests/Feature/Membership/TestersBlockTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Member/Membership.php b/app/Member/Membership.php index 919353e7..dbb5dfa6 100644 --- a/app/Member/Membership.php +++ b/app/Member/Membership.php @@ -100,6 +100,6 @@ class Membership extends Model */ public function scopeTrying(Builder $query): Builder { - return $query->whereHas('activity', fn ($builder) => $builder->where('is_try', true)); + return $query->active()->whereHas('activity', fn ($builder) => $builder->where('is_try', true)); } } diff --git a/tests/Feature/Membership/TestersBlockTest.php b/tests/Feature/Membership/TestersBlockTest.php index 91ddf4f7..617d1fd6 100644 --- a/tests/Feature/Membership/TestersBlockTest.php +++ b/tests/Feature/Membership/TestersBlockTest.php @@ -20,6 +20,10 @@ class TestersBlockTest extends TestCase ->defaults() ->has(Membership::factory()->in('Schnuppermitgliedschaft', 7, 'Wölfling', 8)->state(['created_at' => now()->subMonths(10)])) ->create(['firstname' => 'Max', 'lastname' => 'Muster']); + $inactiveMember = Member::factory() + ->defaults() + ->has(Membership::factory()->ended()->in('Schnuppermitgliedschaft', 7, 'Wölfling', 8)->state(['created_at' => now()->subMonths(10)])) + ->create(['firstname' => 'Max', 'lastname' => 'Muster']); $data = app(TestersBlock::class)->render()['data'];