Fix session form data being reset if throttling kicks in [MAILPOET-2015]

This commit is contained in:
wxa
2019-07-19 13:47:54 +03:00
committed by M. Shull
parent cfb108d240
commit 97f0b9104c
3 changed files with 38 additions and 30 deletions

View File

@ -600,16 +600,14 @@ class SubscribersTest extends \MailPoetTest {
$this->obfuscatedSegments => [$this->segment_1->id, $this->segment_2->id],
]);
try {
$this->endpoint->subscribe([
$this->obfuscatedEmail => 'tata@mailpoet.com',
'form_id' => $this->form->id,
$this->obfuscatedSegments => [$this->segment_1->id, $this->segment_2->id],
]);
$this->fail('It should not be possible to subscribe a second time so soon');
} catch (\Exception $e) {
expect($e->getMessage())->equals('You need to wait 1 minutes before subscribing again.');
}
$response = $this->endpoint->subscribe([
$this->obfuscatedEmail => 'tata@mailpoet.com',
'form_id' => $this->form->id,
$this->obfuscatedSegments => [$this->segment_1->id, $this->segment_2->id],
]);
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('You need to wait 1 minutes before subscribing again.');
}
function testItCannotMassResubscribe() {
@ -627,16 +625,14 @@ class SubscribersTest extends \MailPoetTest {
$subscriber->updated_at = Carbon::now();
$subscriber->save();
try {
$this->endpoint->subscribe([
$this->obfuscatedEmail => $subscriber->email,
'form_id' => $this->form->id,
$this->obfuscatedSegments => [$this->segment_1->id, $this->segment_2->id],
]);
$this->fail('It should not be possible to resubscribe a second time so soon');
} catch (\Exception $e) {
expect($e->getMessage())->equals('You need to wait 1 minutes before subscribing again.');
}
$response = $this->endpoint->subscribe([
$this->obfuscatedEmail => $subscriber->email,
'form_id' => $this->form->id,
$this->obfuscatedSegments => [$this->segment_1->id, $this->segment_2->id],
]);
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('You need to wait 1 minutes before subscribing again.');
}
function testItSchedulesWelcomeEmailNotificationWhenSubscriberIsAdded() {