Skip to content

Commit 6b98393

Browse files
authored
Merge pull request #17973 from marcusmoore/fixes/17972-update-last-checkin-upon-edit
Fixed #17972 - set last_checkin if asset is checked in during an update
2 parents 34fcf5d + 93082e1 commit 6b98393

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/Http/Controllers/Assets/AssetsController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public function update(ImageUploadRequest $request, Asset $asset) : RedirectResp
398398
$asset->assigned_to = null;
399399
$asset->assigned_type = null;
400400
$asset->accepted = null;
401+
$asset->last_checkin = now();
401402
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update with '.$status->getStatuslabelType().' status', date('Y-m-d H:i:s'), $originalValues));
402403
}
403404

tests/Feature/Assets/Ui/EditAssetTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public function testNewCheckinIsLoggedIfStatusChangedToUndeployable()
7575
$user = User::factory()->create();
7676
$deployable_status = Statuslabel::factory()->rtd()->create();
7777
$achived_status = Statuslabel::factory()->archived()->create();
78-
$asset = Asset::factory()->assignedToUser($user)->create(['status_id' => $deployable_status->id]);
78+
$asset = Asset::factory()->assignedToUser($user)->create([
79+
'status_id' => $deployable_status->id,
80+
'last_checkin' => null,
81+
]);
7982
$this->assertTrue($asset->assignedTo->is($user));
8083

8184
$currentTimestamp = now();
@@ -96,6 +99,7 @@ public function testNewCheckinIsLoggedIfStatusChangedToUndeployable()
9699
$this->assertNull($asset->assigned_to);
97100
$this->assertNull($asset->assigned_type);
98101
$this->assertEquals($achived_status->id, $asset->status_id);
102+
$this->assertNotNull($asset->last_checkin);
99103

100104
Event::assertDispatched(function (CheckoutableCheckedIn $event) use ($currentTimestamp) {
101105
return (int) Carbon::parse($event->action_date)->diffInSeconds($currentTimestamp, true) < 2;

0 commit comments

Comments
 (0)