Fix: Dont send yearly mail when yearly prevention is inactive
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
e429d7de76
commit
9d41cdb010
|
@ -22,6 +22,10 @@ class YearlyRememberAction
|
||||||
$settings = app(PreventionSettings::class);
|
$settings = app(PreventionSettings::class);
|
||||||
$expireDate = now()->addWeeks($settings->weeks);
|
$expireDate = now()->addWeeks($settings->weeks);
|
||||||
|
|
||||||
|
if (!$settings->active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
||||||
// @todo add this check to FilterScope
|
// @todo add this check to FilterScope
|
||||||
if ($member->getMailRecipient() === null) {
|
if ($member->getMailRecipient() === null) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ uses(CreatesFormFields::class);
|
||||||
uses(EndToEndTestCase::class);
|
uses(EndToEndTestCase::class);
|
||||||
|
|
||||||
beforeEach(function () {
|
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
|
function createForm(): Form
|
||||||
|
@ -309,6 +309,17 @@ it('doesnt send yearly mail when member has no mail', function () {
|
||||||
Mail::assertNotSent(YearlyMail::class);
|
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 () {
|
it('doesnt send yearly mail when member doesnt match', function () {
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
app(PreventionSettings::class)->fill([
|
app(PreventionSettings::class)->fill([
|
||||||
|
|
Loading…
Reference in New Issue