Prevent sending stats newsletter if tracking is disabled

[MAILPOET-1571]
This commit is contained in:
Pavel Dohnal
2019-01-22 10:47:10 +01:00
parent 627088e43d
commit e76f8d5159
2 changed files with 13 additions and 0 deletions

View File

@ -60,6 +60,9 @@ class Scheduler {
if(empty(trim($settings['address']))) {
return true;
}
if(!(bool)Setting::getValue('tracking.enabled')) {
return true;
}
return !(bool)$settings['enabled'];
}

View File

@ -18,6 +18,7 @@ class SchedulerTest extends \MailPoetTest {
'enabled' => true,
'address' => 'email@example.com'
]);
Setting::setValue('tracking.enabled', true);
}
function testShouldSchedule() {
@ -30,6 +31,15 @@ class SchedulerTest extends \MailPoetTest {
expect($task)->isInstanceOf(ScheduledTask::class);
}
function testShouldNotScheduleIfTrackingIsDisabled() {
Setting::setValue('tracking.enabled', false);
$newsletter_id = 13;
$newsletter = Newsletter::createOrUpdate(['id' => $newsletter_id, 'type' => Newsletter::TYPE_STANDARD]);
$this->stats_notifications->schedule($newsletter);
$notification = StatsNotification::where('newsletter_id', $newsletter_id)->findOne();
expect($notification)->isEmpty();
}
function testShouldNotScheduleIfDisabled() {
$newsletter_id = 6;
Setting::setValue(Worker::SETTINGS_KEY, [