Fixed tests again

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-11 17:29:22 +01:00
parent 43250ae881
commit a97530367d
3 changed files with 11 additions and 8 deletions

View file

@ -331,14 +331,14 @@ class AssetsController extends Controller
$asset->expected_checkin = $request->input('expected_checkin', null);
// If the box isn't checked, it's not in the request at all.
$asset->requestable = $request->filled('requestable');
$asset->requestable = $request->filled('requestable', 0);
$asset->rtd_location_id = $request->input('rtd_location_id', null);
$asset->byod = $request->input('byod', 0);
$status = Statuslabel::find($asset->status_id);
$status = Statuslabel::find($request->input('status_id'));
// This is a non-deployable status label - we should check the asset back in.
if (($status && $status->getStatuslabelType() != 'deployable') && (is_null($target = $asset->assignedTo))) {
if (($status && $status->getStatuslabelType() != 'deployable') && ($target = $asset->assignedTo)) {
$originalValues = $asset->getRawOriginal();
$asset->assigned_to = null;

View file

@ -263,7 +263,7 @@
$("#assignto_selector").hide();
$("#selected_status_status").removeClass('text-success');
$("#selected_status_status").addClass('text-danger');
$("#selected_status_status").html('<x-icon type="warning" /> {{ (($item->assignedTo) && ($item->deleted_at == '')) ? trans('admin/hardware/form.asset_not_deployable_checkin') : trans('admin/hardware/form.asset_not_deployable') }} ');
$("#selected_status_status").html('<x-icon type="warning" /> {{ (($item->assigned_to!='') && ($item->assigned_type!='') && ($item->deleted_at == '')) ? trans('admin/hardware/form.asset_not_deployable_checkin') : trans('admin/hardware/form.asset_not_deployable') }} ');
}
}
});

View file

@ -81,16 +81,19 @@ class EditAssetTest extends TestCase
$currentTimestamp = now();
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
->from(route('hardware.edit', $asset))
->patch(route('hardware.update', $asset), [
->from(route('hardware.edit', $asset->id))
->put(route('hardware.update', $asset->id), [
'status_id' => $achived_status->id,
'model_id' => $asset->model_id,
'asset_tag' => $asset->asset_tag,
'asset_tags' => $asset->asset_tag,
],
)
->assertStatus(302);
//->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));;
$asset->refresh();
// $asset->refresh();
$asset = Asset::find($asset->id);
$this->assertNull($asset->assigned_to);
$this->assertNull($asset->assigned_type);
$this->assertEquals($achived_status->id, $asset->status_id);