Merge pull request #13842 from marcusmoore/bug/sc-23932

Fixed notes not saving to action log when licenses are checked in/out
This commit is contained in:
snipe 2023-11-08 08:53:00 +00:00 committed by GitHub
commit 44d064f094
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 3 deletions

View file

@ -101,7 +101,7 @@ class LicenseCheckinController extends Controller
// Was the asset updated?
if ($licenseSeat->save()) {
event(new CheckoutableCheckedIn($licenseSeat, $return_to, Auth::user(), $request->input('note')));
event(new CheckoutableCheckedIn($licenseSeat, $return_to, Auth::user(), $request->input('notes')));
if ($backTo == 'user') {
return redirect()->route('users.show', $return_to->id)->with('success', trans('admin/licenses/message.checkin.success'));

View file

@ -105,7 +105,7 @@ class LicenseCheckoutController extends Controller
$licenseSeat->assigned_to = $target->assigned_to;
}
if ($licenseSeat->save()) {
event(new CheckoutableCheckedOut($licenseSeat, $target, Auth::user(), request('note')));
event(new CheckoutableCheckedOut($licenseSeat, $target, Auth::user(), request('notes')));
return true;
}
@ -122,7 +122,7 @@ class LicenseCheckoutController extends Controller
$licenseSeat->assigned_to = request('assigned_to');
if ($licenseSeat->save()) {
event(new CheckoutableCheckedOut($licenseSeat, $target, Auth::user(), request('note')));
event(new CheckoutableCheckedOut($licenseSeat, $target, Auth::user(), request('notes')));
return true;
}

View file

@ -0,0 +1,62 @@
<?php
namespace Tests\Feature\Checkouts;
use App\Models\Asset;
use App\Models\License;
use App\Models\LicenseSeat;
use App\Models\User;
use Tests\Support\InteractsWithSettings;
use Tests\TestCase;
class LicenseCheckoutTest extends TestCase
{
use InteractsWithSettings;
public function testNotesAreStoredInActionLogOnCheckoutToAsset()
{
$admin = User::factory()->superuser()->create();
$asset = Asset::factory()->create();
$licenseSeat = LicenseSeat::factory()->create();
$this->actingAs($admin)
->post("/licenses/{$licenseSeat->license->id}/checkout", [
'checkout_to_type' => 'asset',
'assigned_to' => null,
'asset_id' => $asset->id,
'notes' => 'oh hi there',
]);
$this->assertDatabaseHas('action_logs', [
'action_type' => 'checkout',
'target_id' => $asset->id,
'target_type' => Asset::class,
'item_id' => $licenseSeat->license->id,
'item_type' => License::class,
'note' => 'oh hi there',
]);
}
public function testNotesAreStoredInActionLogOnCheckoutToUser()
{
$admin = User::factory()->superuser()->create();
$licenseSeat = LicenseSeat::factory()->create();
$this->actingAs($admin)
->post("/licenses/{$licenseSeat->license->id}/checkout", [
'checkout_to_type' => 'user',
'assigned_to' => $admin->id,
'asset_id' => null,
'notes' => 'oh hi there',
]);
$this->assertDatabaseHas('action_logs', [
'action_type' => 'checkout',
'target_id' => $admin->id,
'target_type' => User::class,
'item_id' => $licenseSeat->license->id,
'item_type' => License::class,
'note' => 'oh hi there',
]);
}
}