Prevent resending emails in case the email is not active
Automation email needs to be active in order to be sent. If we allow resending to inactive emails, we would need to activate them first, but this could be an unexpected side effect. And activating may cause sending other paused tasks as a side effect. I expect the email to be active in the majority of cases, so users should not meet this notice very often. [MAILPOET-6241]
This commit is contained in:
committed by
Aschepikov
parent
79de8cc17c
commit
55f2d83abb
@ -244,4 +244,32 @@ class SendingTaskSubscribersTest extends \MailPoetTest {
|
||||
verify($failedSubscriberTask->getProcessed())->equals(0);
|
||||
verify($failedSubscriberTask->getFailed())->equals(0);
|
||||
}
|
||||
|
||||
public function testItPreventResendingInactiveAutomationEmail() {
|
||||
$newsletter = (new NewsletterFactory())->withSubject('My Automatic Newsletter')
|
||||
->withType(NewsletterEntity::TYPE_AUTOMATION)
|
||||
->withStatus(NewsletterEntity::STATUS_DRAFT)
|
||||
->withBody(Fixtures::get('newsletter_body_template'))
|
||||
->withSendingQueue()
|
||||
->create();
|
||||
|
||||
$queue = $newsletter->getLatestQueue();
|
||||
$task = $queue->getTask();
|
||||
|
||||
$failedSubscriber = $this->subscriberFactory
|
||||
->withEmail('failed2@example.com')
|
||||
->withFirstName('Failed')
|
||||
->withLastName('Test')
|
||||
->create();
|
||||
$this->taskSubscriberFactory->createFailed($task, $failedSubscriber, 'Something went wrong!');
|
||||
|
||||
$res = $this->endpoint->resend([
|
||||
'taskId' => $task->getId(),
|
||||
'subscriberId' => $failedSubscriber->getId(),
|
||||
]);
|
||||
|
||||
verify($res->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||
verify($res->errors[0]['message'])
|
||||
->equals('Failed to resend! The email is not active. Please activate it first.');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user