Skip to content

A free open source IT asset/license management system

Fixed flappy test

snipe51a4e1a198b0
diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php
index 7aa032d68a..7ef978ef87 100644
--- a/database/factories/CheckoutAcceptanceFactory.php
+++ b/database/factories/CheckoutAcceptanceFactory.php
@@ -100,12 +100,22 @@ class CheckoutAcceptanceFactory extends Factory
private function createdAssociatedActionLogEntry(CheckoutAcceptance $acceptance): void
{
+ // Match the log entry's created_at to the acceptance's created_at
+ // explicitly. ReportsController::sentAssetAcceptanceReminder
+ // joins the two on WHERE created_at = ?, and TIMESTAMP columns
+ // store second precision — so if the acceptance's default
+ // timestamp and this insert's default timestamp straddle a second
+ // boundary (under full-suite load, often enough to matter), the
+ // join returns nothing and the reminder path bails with an error.
+ // Passing the acceptance's created_at through makes the pair
+ // deterministically identical.
$acceptance->checkoutable->assetlog()->create([
'action_type' => 'checkout',
'target_id' => $acceptance->assigned_to_id,
'target_type' => User::class,
'item_id' => $acceptance->checkoutable_id,
'item_type' => $acceptance->checkoutable_type,
+ 'created_at' => $acceptance->created_at,
]);
}
}