mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Include user's name in Acceptance result notifications for accessories
This commit is contained in:
parent
f96d8fe674
commit
4a0b3efd1f
|
@ -121,7 +121,6 @@ class AcceptanceController extends Controller
|
|||
$pdf_filename = 'accepted-eula-'.date('Y-m-d-h-i-s').'.pdf';
|
||||
$sig_filename='';
|
||||
|
||||
|
||||
if ($request->input('asset_acceptance') == 'accepted') {
|
||||
|
||||
/**
|
||||
|
@ -153,7 +152,6 @@ class AcceptanceController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// this is horrible
|
||||
switch($acceptance->checkoutable_type){
|
||||
case 'App\Models\Asset':
|
||||
|
@ -167,7 +165,7 @@ class AcceptanceController extends Controller
|
|||
$pdf_view_route ='account.accept.accept-accessory-eula';
|
||||
$accessory = Accessory::find($item->id);
|
||||
$display_model = $accessory->name;
|
||||
$assigned_to = User::find($item->assignedTo);
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
|
||||
case 'App\Models\LicenseSeat':
|
||||
|
@ -254,7 +252,7 @@ class AcceptanceController extends Controller
|
|||
break;
|
||||
|
||||
case 'App\Models\Accessory':
|
||||
$assigned_to = User::find($item->assignedTo);
|
||||
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
|
||||
break;
|
||||
|
||||
case 'App\Models\LicenseSeat':
|
||||
|
|
|
@ -291,7 +291,8 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
|
|||
Route::get('accept/{id}', [Account\AcceptanceController::class, 'create'])
|
||||
->name('account.accept.item');
|
||||
|
||||
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store']);
|
||||
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store'])
|
||||
->name('account.store-acceptance');
|
||||
|
||||
Route::get(
|
||||
'print',
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\CheckoutAcceptances;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\CheckoutAcceptance;
|
||||
use App\Notifications\AcceptanceAssetAcceptedNotification;
|
||||
use App\Notifications\AcceptanceAssetDeclinedNotification;
|
||||
use Notification;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AccessoryAcceptanceTest extends TestCase
|
||||
{
|
||||
use InteractsWithSettings;
|
||||
|
||||
/**
|
||||
* This can be absorbed into a bigger test
|
||||
*/
|
||||
public function testUsersNameIsIncludedInAccessoryAcceptedNotification()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$this->settings->enableAlertEmail();
|
||||
|
||||
$acceptance = CheckoutAcceptance::factory()
|
||||
->pending()
|
||||
->for(Accessory::factory()->appleMouse(), 'checkoutable')
|
||||
->create();
|
||||
|
||||
$this->actingAs($acceptance->assignedTo)
|
||||
->post(route('account.store-acceptance', $acceptance), ['asset_acceptance' => 'accepted'])
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertNotNull($acceptance->fresh()->accepted_at);
|
||||
|
||||
Notification::assertSentTo(
|
||||
$acceptance,
|
||||
function (AcceptanceAssetAcceptedNotification $notification) use ($acceptance) {
|
||||
$this->assertStringContainsString(
|
||||
$acceptance->assignedTo->present()->fullName,
|
||||
$notification->toMail()->render()
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be absorbed into a bigger test
|
||||
*/
|
||||
public function testUsersNameIsIncludedInAccessoryDeclinedNotification()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$this->settings->enableAlertEmail();
|
||||
|
||||
$acceptance = CheckoutAcceptance::factory()
|
||||
->pending()
|
||||
->for(Accessory::factory()->appleMouse(), 'checkoutable')
|
||||
->create();
|
||||
|
||||
$this->actingAs($acceptance->assignedTo)
|
||||
->post(route('account.store-acceptance', $acceptance), ['asset_acceptance' => 'declined'])
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertNotNull($acceptance->fresh()->declined_at);
|
||||
|
||||
Notification::assertSentTo(
|
||||
$acceptance,
|
||||
function (AcceptanceAssetDeclinedNotification $notification) use ($acceptance) {
|
||||
$this->assertStringContainsString(
|
||||
$acceptance->assignedTo->present()->fullName,
|
||||
$notification->toMail($acceptance)->render()
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,16 @@ class Settings
|
|||
return new self();
|
||||
}
|
||||
|
||||
public function enableAlertEmail(string $email = 'notifications@afcrichmond.com'): Settings
|
||||
{
|
||||
return $this->update(['alert_email' => $email]);
|
||||
}
|
||||
|
||||
public function disableAlertEmail(): Settings
|
||||
{
|
||||
return $this->update(['alert_email' => null]);
|
||||
}
|
||||
|
||||
public function enableMultipleFullCompanySupport(): Settings
|
||||
{
|
||||
return $this->update(['full_multiple_companies_support' => 1]);
|
||||
|
|
Loading…
Reference in a new issue