Set the calendar's daily capacity in the company details
The task calendar's daily maximum moves from the hidden setting jobs.daily_capacity_hours to shared.daily_capacity_hours, edited by the admin on the company details page. An empty field means 7.5 hours. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use App\Modules\Shared\Application\UseCases\DailyCapacity;
|
||||
use App\Modules\Shared\Domain\Exceptions\InvalidDailyCapacity;
|
||||
use Tests\Fakes\FakeSettings;
|
||||
|
||||
it('is 7.5 hours until set', function () {
|
||||
$capacity = new DailyCapacity(new FakeSettings);
|
||||
|
||||
expect($capacity->minutes())->toBe(450)
|
||||
->and($capacity->hours())->toBeNull();
|
||||
});
|
||||
|
||||
it('saves hours with a comma or a point and clears them when empty', function () {
|
||||
$settings = new FakeSettings;
|
||||
$capacity = new DailyCapacity($settings);
|
||||
|
||||
$capacity->save(' 6,5 ');
|
||||
expect($capacity->minutes())->toBe(390)
|
||||
->and($capacity->hours())->toBe('6,5')
|
||||
->and($settings->get(DailyCapacity::KEY))->toBe('6.5');
|
||||
|
||||
$capacity->save('8.0');
|
||||
expect($capacity->minutes())->toBe(480)
|
||||
->and($capacity->hours())->toBe('8');
|
||||
|
||||
$capacity->save('');
|
||||
expect($capacity->minutes())->toBe(450)
|
||||
->and($settings->get(DailyCapacity::KEY))->toBeNull();
|
||||
});
|
||||
|
||||
it('rejects hours that are not more than 0 and at most 24', function (string $hours) {
|
||||
expect(DailyCapacity::isValid($hours))->toBeFalse()
|
||||
->and(fn () => (new DailyCapacity(new FakeSettings))->save($hours))->toThrow(InvalidDailyCapacity::class);
|
||||
})->with(['0', '-1', '24,5', 'abc', '7,5 h']);
|
||||
Reference in New Issue
Block a user