mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
messing with the tests
This commit is contained in:
parent
ff113ef523
commit
1e31592c55
|
@ -59,16 +59,15 @@ class CheckoutableListener
|
|||
$mailable->locale($event->checkedOutTo->locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an email if any of the following conditions are met:
|
||||
* 1. The asset requires acceptance
|
||||
* 2. The item has a EULA
|
||||
* 3. The item should send an email at check-in/check-out
|
||||
*/
|
||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||
|
||||
/**
|
||||
* Send an email if any of the following conditions are met:
|
||||
* 1. The asset requires acceptance
|
||||
* 2. The item has a EULA
|
||||
* 3. The item should send an email at check-in/check-out
|
||||
*/
|
||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||
Mail::to($notifiable)->send($mailable);
|
||||
Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default'));
|
||||
}
|
||||
|
@ -115,14 +114,25 @@ class CheckoutableListener
|
|||
|
||||
$notifiable = $event->checkedInBy;
|
||||
$mailable = $this->getCheckinMailType($event);
|
||||
|
||||
// Send email notifications
|
||||
try {
|
||||
if (!$event->checkedOutTo->locale){
|
||||
$mailable->locale($event->checkedOutTo->locale);
|
||||
}
|
||||
Mail::to($notifiable)->send($mailable);
|
||||
\Log::info('Sending email, Locale: ' .$event->checkedOutTo->locale);
|
||||
/**
|
||||
* Send an email if any of the following conditions are met:
|
||||
* 1. The asset requires acceptance
|
||||
* 2. The item has a EULA
|
||||
* 3. The item should send an email at check-in/check-out
|
||||
*/
|
||||
|
||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||
Mail::to($notifiable)->send($mailable);
|
||||
Log::info('Sending email, Locale: ' . $event->checkedOutTo->locale);
|
||||
}
|
||||
}
|
||||
// Send Webhook notification
|
||||
if ($this->shouldSendWebhookNotification()) {
|
||||
Notification::route(Setting::getSettings()->webhook_selected, Setting::getSettings()->webhook_endpoint)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Tests\Feature\Checkins\Ui;
|
||||
|
||||
use App\Events\CheckoutableCheckedIn;
|
||||
use App\Mail\CheckoutAccessoryMail;
|
||||
use App\Mail\CheckinAccessoryMail;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckinAccessoryNotification;
|
||||
|
@ -56,8 +56,8 @@ class AccessoryCheckinTest extends TestCase
|
|||
'',
|
||||
));
|
||||
|
||||
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||
Mail::assertSent(CheckinAccessoryMail::class, function ($mail) use ( $user) {
|
||||
return $mail->hasTo($user->email);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class AccessoryCheckinTest extends TestCase
|
|||
'',
|
||||
));
|
||||
|
||||
Mail::assertNotSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||
Mail::assertNotSent(CheckinAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class ConsumableCheckoutTest extends TestCase
|
|||
'assigned_to' => $user->id,
|
||||
]);
|
||||
|
||||
Mail::assertNotSent(CheckoutConsumableMail::class, function ($mail) use ($user) {
|
||||
Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($user) {
|
||||
return $mail->hasTo($user->email);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ class EmailNotificationsUponCheckinTest extends TestCase
|
|||
|
||||
$this->fireCheckInEvent($asset, $user);
|
||||
|
||||
Mail::assertSent(CheckinAssetMail::class, function($mail) use ($user, $asset) {
|
||||
return $mail->hasTo($user->email) && $mail->event->checkoutable->id === $asset->id;
|
||||
Mail::assertSent(CheckinAssetMail::class, function($mail) use ($user) {
|
||||
return $mail->hasTo($user->email);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue