Skip to content

Commit

Permalink
Fixed tests again
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed Sep 11, 2024
1 parent 43250ae commit a975303
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Assets/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ public function update(ImageUploadRequest $request, $assetId = null) : RedirectR
$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;
Expand Down
2 changes: 1 addition & 1 deletion resources/views/hardware/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function user_add(status_id) {
$("#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') }} ');
}
}
});
Expand Down
11 changes: 7 additions & 4 deletions tests/Feature/Assets/Ui/EditAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,19 @@ public function testNewCheckinIsLoggedIfStatusChangedToUndeployable()
$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);

Expand Down

0 comments on commit a975303

Please sign in to comment.