mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #16106 from marcusmoore/bug/sc-27960
Fixed asset show page erroring when asset not associated with model
This commit is contained in:
commit
5fa4f85c20
|
@ -1440,6 +1440,7 @@
|
|||
</div> <!-- /.row -->
|
||||
</div> <!-- /.tab-pane files -->
|
||||
|
||||
@if ($asset->model)
|
||||
@can('view', $asset->model)
|
||||
<div class="tab-pane fade" id="modelfiles">
|
||||
<div class="row{{ (($asset->model) && ($asset->model->uploads->count() > 0)) ? '' : ' hidden-print' }}">
|
||||
|
@ -1455,6 +1456,7 @@
|
|||
</div> <!-- /.row -->
|
||||
</div> <!-- /.tab-pane files -->
|
||||
@endcan
|
||||
@endif
|
||||
</div><!-- /.tab-content -->
|
||||
</div><!-- nav-tabs-custom -->
|
||||
</div>
|
||||
|
|
26
tests/Feature/Assets/Ui/ShowAssetTest.php
Normal file
26
tests/Feature/Assets/Ui/ShowAssetTest.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Assets\Ui;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ShowAssetTest extends TestCase
|
||||
{
|
||||
public function testPageForAssetWithMissingModelStillRenders()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$asset->model_id = null;
|
||||
$asset->forceSave();
|
||||
|
||||
$asset->refresh();
|
||||
|
||||
$this->assertNull($asset->fresh()->model_id, 'This test needs model_id to be null to be helpful.');
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->get(route('hardware.show', $asset))
|
||||
->assertOk();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue