Fix: Dont remember past events
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2024-11-20 11:10:24 +01:00
parent c990ce3171
commit 9fc8548504
2 changed files with 18 additions and 1 deletions

View File

@ -17,7 +17,12 @@ class PreventionRememberAction
public function handle(): void
{
$query = Participant::whereHas('form', fn ($form) => $form->where('needs_prevention', true))
$query = Participant::whereHas(
'form',
fn ($form) => $form
->where('needs_prevention', true)
->where('from', '>=', now())
)
->where(
fn ($q) => $q
->where('last_remembered_at', '<=', now()->subWeeks(2))

View File

@ -39,6 +39,18 @@ class PreventionTest extends TestCase
$this->assertEquals(now()->format('Y-m-d'), $participant->fresh()->last_remembered_at->format('Y-m-d'));
}
public function testItDoesntRememberPastEvents(): void
{
Mail::fake();
$form = $this->createForm();
$participant = $this->createParticipant($form);
$form->update(['from' => now()->subDay()]);
PreventionRememberAction::run();
$this->assertNull($participant->fresh()->last_remembered_at);
}
public function testItDoesntRememberWhenConditionDoesntMatch(): void
{
Mail::fake();