fix work log suggestion during the event

This commit is contained in:
Xu 2023-08-15 23:02:26 +02:00 committed by Igor Scheller
parent e03f2936e7
commit b5803caf44
2 changed files with 1 additions and 36 deletions

View File

@ -52,7 +52,7 @@ class UserWorkLogController extends BaseController
} }
return $this->showEditWorklog($user, $worklog->worked_at, $worklog->hours, $worklog->comment, true); return $this->showEditWorklog($user, $worklog->worked_at, $worklog->hours, $worklog->comment, true);
} else { } else {
return $this->showEditWorklog($user, $this->getWorkDateSuggestion()); return $this->showEditWorklog($user, Carbon::today());
} }
} }
@ -145,16 +145,4 @@ class UserWorkLogController extends BaseController
] ]
); );
} }
private function getWorkDateSuggestion(): Carbon
{
$buildup_start = config('buildup_start');
$event_start = config('event_start');
$work_date_suggestion = Carbon::today();
if (!empty($buildup_start) && (empty($event_start) || $event_start->lessThan(Carbon::now()))) {
$work_date_suggestion = $buildup_start->startOfDay();
}
return $work_date_suggestion;
}
} }

View File

@ -60,29 +60,6 @@ class UserWorkLogControllerTest extends ControllerTest
$this->controller->editWorklog($request); $this->controller->editWorklog($request);
} }
/**
* @covers \Engelsystem\Controllers\Admin\UserWorkLogController::editWorklog
* @covers \Engelsystem\Controllers\Admin\UserWorkLogController::getWorkDateSuggestion
*
* @dataProvider buildupConfigsAndWorkDates
*/
public function testShowAddWorklogWithSuggestedWorkDate(
Carbon|null $buildup_start,
Carbon|null $event_start,
Carbon $suggested_work_date
): void {
$request = $this->request->withAttribute('user_id', $this->user->id);
config(['buildup_start' => $buildup_start]);
config(['event_start' => $event_start]);
$this->response->expects($this->once())
->method('withView')
->willReturnCallback(function (string $view, array $data) use ($suggested_work_date) {
$this->assertEquals($suggested_work_date, $data['work_date']);
return $this->response;
});
$this->controller->editWorklog($request);
}
/** /**
* @covers \Engelsystem\Controllers\Admin\UserWorkLogController::editWorklog * @covers \Engelsystem\Controllers\Admin\UserWorkLogController::editWorklog
*/ */