mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
fixes test to check if checked in licenses is unavailable
This commit is contained in:
parent
7a23372489
commit
344b4e7d60
|
@ -95,9 +95,10 @@ class LicenseCheckinController extends Controller
|
||||||
$licenseSeat->assigned_to = null;
|
$licenseSeat->assigned_to = null;
|
||||||
$licenseSeat->asset_id = null;
|
$licenseSeat->asset_id = null;
|
||||||
$licenseSeat->notes = $request->input('notes');
|
$licenseSeat->notes = $request->input('notes');
|
||||||
if (! $license->reassignable) {
|
if (! $licenseSeat->license->reassignable) {
|
||||||
$licenseSeat->unavailable = 1;
|
$licenseSeat->unavailable = 1;
|
||||||
$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';
|
$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||||
|
|
|
@ -14,6 +14,7 @@ class LicenseSeatFactory extends Factory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'license_id' => License::factory(),
|
'license_id' => License::factory(),
|
||||||
|
'unavailable' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class LicenseCheckinTest extends TestCase
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotCheckinNonReassignableLicense()
|
public function testNonReassignableLicenseSeatIsUnavailable()
|
||||||
{
|
{
|
||||||
$licenseSeat = LicenseSeat::factory()
|
$licenseSeat = LicenseSeat::factory()
|
||||||
->notReassignable()
|
->notReassignable()
|
||||||
|
@ -28,13 +28,11 @@ class LicenseCheckinTest extends TestCase
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkoutLicenses()->create())
|
$this->actingAs(User::factory()->checkoutLicenses()->create())
|
||||||
->post(route('licenses.checkin.save', $licenseSeat), [
|
->post(route('licenses.checkin.save', $licenseSeat));
|
||||||
'notes' => 'my note',
|
|
||||||
'redirect_option' => 'index',
|
|
||||||
])
|
|
||||||
->assertSessionHas('error', trans('admin/licenses/message.checkin.not_reassignable') . '.');
|
|
||||||
|
|
||||||
$this->assertNotNull($licenseSeat->fresh()->assigned_to);
|
$licenseSeat->refresh();
|
||||||
|
|
||||||
|
$this->assertEquals(1, $licenseSeat->unavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotCheckinLicenseThatIsNotAssigned()
|
public function testCannotCheckinLicenseThatIsNotAssigned()
|
||||||
|
|
Loading…
Reference in a new issue