Fix: Dont send yearly mail when yearly prevention is inactive
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2025-05-30 19:13:38 +02:00
parent e429d7de76
commit 9d41cdb010
2 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,10 @@ class YearlyRememberAction
$settings = app(PreventionSettings::class);
$expireDate = now()->addWeeks($settings->weeks);
if (!$settings->active) {
return;
}
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
// @todo add this check to FilterScope
if ($member->getMailRecipient() === null) {

View File

@ -28,7 +28,7 @@ uses(CreatesFormFields::class);
uses(EndToEndTestCase::class);
beforeEach(function () {
app(PreventionSettings::class)->fill(['preventAgainst' => array_column(Prevention::values(), 'id')])->save();
app(PreventionSettings::class)->fill(['preventAgainst' => array_column(Prevention::values(), 'id'), 'active' => true])->save();
});
function createForm(): Form
@ -309,6 +309,17 @@ it('doesnt send yearly mail when member has no mail', function () {
Mail::assertNotSent(YearlyMail::class);
});
it('doesnt send yearly mail when yearly sending is deactivated', function () {
Mail::fake();
app(PreventionSettings::class)->fill(['active' => false])->save();
createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]);
sleep(2);
YearlyRememberAction::run();
Mail::assertNotSent(YearlyMail::class);
});
it('doesnt send yearly mail when member doesnt match', function () {
Mail::fake();
app(PreventionSettings::class)->fill([