mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
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:
commit
44d064f094
|
@ -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'));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
62
tests/Feature/Checkouts/LicenseCheckoutTest.php
Normal file
62
tests/Feature/Checkouts/LicenseCheckoutTest.php
Normal 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',
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue