Merge pull request #16527 from Godmartinz/license_seat_notes_fix
add notes as fillable to license seat model
This commit is contained in:
commit
fe65ffc384
4 changed files with 89 additions and 2 deletions
|
@ -136,13 +136,13 @@ class LicenseSeatsController extends Controller
|
||||||
if ($licenseSeat->save()) {
|
if ($licenseSeat->save()) {
|
||||||
|
|
||||||
if ($is_checkin) {
|
if ($is_checkin) {
|
||||||
$licenseSeat->logCheckin($target, $request->input('note'));
|
$licenseSeat->logCheckin($target, $request->input('notes'));
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// in this case, relevant fields are touched but it's not a checkin operation. so it must be a checkout operation.
|
// in this case, relevant fields are touched but it's not a checkin operation. so it must be a checkout operation.
|
||||||
$licenseSeat->logCheckout($request->input('note'), $target);
|
$licenseSeat->logCheckout($request->input('notes'), $target);
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'assigned_to',
|
'assigned_to',
|
||||||
'asset_id',
|
'asset_id',
|
||||||
|
'notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
use Acceptable;
|
use Acceptable;
|
||||||
|
|
45
tests/Feature/Checkins/Api/LicenseCheckInTest.php
Normal file
45
tests/Feature/Checkins/Api/LicenseCheckInTest.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
namespace Tests\Feature\Checkins\Api;
|
||||||
|
|
||||||
|
use App\Models\License;
|
||||||
|
use App\Models\LicenseSeat;
|
||||||
|
use App\Models\User;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class LicenseCheckInTest extends TestCase {
|
||||||
|
public function testLicenseCheckin()
|
||||||
|
{
|
||||||
|
$authUser = User::factory()->superuser()->create();
|
||||||
|
$this->actingAsForApi($authUser);
|
||||||
|
|
||||||
|
$license = License::factory()->create();
|
||||||
|
$oldUser = User::factory()->create();
|
||||||
|
|
||||||
|
$licenseSeat = LicenseSeat::factory()->for($license)->create([
|
||||||
|
'assigned_to' => $oldUser->id,
|
||||||
|
'notes' => 'Previously checked out',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'assigned_to' => null,
|
||||||
|
'asset_id' => null,
|
||||||
|
'notes' => 'Checking in the seat',
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->patchJson(
|
||||||
|
route('api.licenses.seats.update', [$license->id, $licenseSeat->id]),
|
||||||
|
$payload);
|
||||||
|
|
||||||
|
$response->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'status' => 'success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$licenseSeat->refresh();
|
||||||
|
|
||||||
|
$this->assertNull($licenseSeat->assigned_to);
|
||||||
|
$this->assertNull($licenseSeat->asset_id);
|
||||||
|
|
||||||
|
$this->assertEquals('Checking in the seat', $licenseSeat->notes);
|
||||||
|
}
|
||||||
|
}
|
41
tests/Feature/Checkouts/Api/LicenseCheckOutTest.php
Normal file
41
tests/Feature/Checkouts/Api/LicenseCheckOutTest.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
namespace Tests\Feature\Checkouts\Api;
|
||||||
|
|
||||||
|
use App\Models\License;
|
||||||
|
use App\Models\LicenseSeat;
|
||||||
|
use App\Models\User;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class LicenseCheckOutTest extends TestCase {
|
||||||
|
public function testLicenseCheckout()
|
||||||
|
{
|
||||||
|
$authUser = User::factory()->superuser()->create();
|
||||||
|
$this->actingAsForApi($authUser);
|
||||||
|
|
||||||
|
$license = License::factory()->create();
|
||||||
|
$licenseSeat = LicenseSeat::factory()->for($license)->create([
|
||||||
|
'assigned_to' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$targetUser = User::factory()->create();
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'assigned_to' => $targetUser->id,
|
||||||
|
'notes' => 'Checking out the seat to a user',
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->patchJson(
|
||||||
|
route('api.licenses.seats.update', [$license->id, $licenseSeat->id]),
|
||||||
|
$payload);
|
||||||
|
|
||||||
|
$response->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'status' => 'success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$licenseSeat->refresh();
|
||||||
|
|
||||||
|
$this->assertEquals($targetUser->id, $licenseSeat->assigned_to);
|
||||||
|
$this->assertEquals('Checking out the seat to a user', $licenseSeat->notes);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue