Additional checks when validating sendemailrequest
This commit is contained in:
parent
30b4ed191f
commit
9619c65900
|
|
@ -85,7 +85,7 @@ class SendEmailRequest extends Request
|
|||
$input['template'] = '';
|
||||
}
|
||||
|
||||
if (! property_exists($settings, $input['template'])) {
|
||||
if (is_string($input['template']) && ! property_exists($settings, $input['template'])) {
|
||||
unset($input['template']);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class QuoteReminderJob implements ShouldQueue
|
|||
$t->replace(Ninja::transformTranslations($quote->client->getMergedSettings()));
|
||||
App::setLocale($quote->client->locale());
|
||||
|
||||
if ($quote->isPayable()) {
|
||||
if ($quote->canRemind()) {
|
||||
//Attempts to prevent duplicates from sending
|
||||
if ($quote->reminder_last_sent && Carbon::parse($quote->reminder_last_sent)->startOfDay()->eq(now()->startOfDay())) {
|
||||
nrlog("caught a duplicate reminder for quote {$quote->number}");
|
||||
|
|
|
|||
|
|
@ -57,6 +57,31 @@ class InvoiceEmailTest extends TestCase
|
|||
$this->assertTrue(strpos($email, '@example.com') !== false);
|
||||
}
|
||||
|
||||
|
||||
public function testTemplateValidationWhenArray()
|
||||
{
|
||||
$data = [
|
||||
"body" => "hey what's up",
|
||||
"entity" => 'blergen',
|
||||
"entity_id" => $this->invoice->hashed_id,
|
||||
"subject" => 'Reminder $number',
|
||||
"template" => [
|
||||
"email_template_invoice","noo",
|
||||
],
|
||||
];
|
||||
|
||||
$response = false;
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/emails', $data);
|
||||
|
||||
$response->assertStatus(422);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testEntityValidation()
|
||||
{
|
||||
$data = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue