refactor(team): make server limit methods accept optional team parameter

Allow serverLimit() and serverLimitReached() to accept an optional team
parameter instead of relying solely on the current session. This improves
testability and makes the methods more flexible by allowing them to work
without session state.

Add comprehensive tests covering various scenarios including no session,
team at limit, and team under limit.
This commit is contained in:
Andras Bacsai
2026-03-23 21:56:50 +01:00
parent 8457e22863
commit e37cb98c7c
3 changed files with 68 additions and 7 deletions
@@ -586,7 +586,8 @@ class HetznerController extends Controller
}
// Check server limit
if (Team::serverLimitReached()) {
$team = Team::find($teamId);
if (Team::serverLimitReached($team)) {
return response()->json(['message' => 'Server limit reached for your subscription.'], 400);
}