Skip to content

Commit

Permalink
adjust for db limit, create test
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentauger committed Dec 2, 2024
1 parent e66d660 commit 5835aec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/AuthorEmploymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function store(Author $author, Request $request)

$validated = $request->validate([
'organization_id' => 'nullable|exists:organizations,id',
'role_title' => 'nullable|string|max:255',
'department_name' => 'nullable|string|max:255',
'role_title' => 'nullable|string|max:125',
'department_name' => 'nullable|string|max:125',
'start_date' => 'required|date',
'end_date' => 'nullable|date',
]);
Expand Down Expand Up @@ -81,8 +81,8 @@ public function update(Author $author, Request $request, AuthorEmployment $autho
$this->authorize('update', $authorEmployment);

$validated = $request->validate([
'role_title' => 'nullable|string|max:50',
'department_name' => 'nullable|string|max:50',
'role_title' => 'nullable|string|max:125',
'department_name' => 'nullable|string|max:125',
'start_date' => 'required|date',
'end_date' => 'nullable|date',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function createAuthorEmployment() {
:label="t('orcid-employment-edit.role-title')"
outlined
:rules="[(val: string|null) => !!val || t('common.required'),
(val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]),
(val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
]"
class="q-mb-md"
/>
Expand All @@ -74,7 +74,7 @@ async function createAuthorEmployment() {
:label="t('orcid-employment-edit.department-name')"
outlined
:rules="[(val: string|null) => !!val || t('common.required'),
(val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]),
(val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
]"
class="q-mb-md"
:hint="t('orcid-employment-edit.department-name-hint')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function deleteAuthorEmployment() {
:label="t('orcid-employment-edit.role-title')"
outlined
:rules="[(val: string|null) => !!val || t('common.required'),
(val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]),
(val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
]"
class="q-mb-md"
/>
Expand All @@ -87,7 +87,7 @@ function deleteAuthorEmployment() {
:label="t('orcid-employment-edit.department-name')"
outlined
:rules="[(val: string|null) => !!val || t('common.required'),
(val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]),
(val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
]"
class="q-mb-md"
:hint="t('orcid-employment-edit.department-name-hint')"
Expand Down
21 changes: 21 additions & 0 deletions tests/Feature/Models/AuthorEmployementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,24 @@
Queue::assertPushed(\App\Jobs\SyncAuthorEmploymentWithOrcid::class);

});

test('adding a 125 char role title is valid', function () {
$user = User::factory()->create();
$employment = AuthorEmployment::factory()->create([
'author_id' => $user->author->id,
'organization_id' => Organization::getDefaultOrganization()->id,
'start_date' => now()->subYear(),
]);

$data = AuthorEmployment::factory()->make([
'author_id' => $user->author->id,
'organization_id' => Organization::getDefaultOrganization()->id,
'start_date' => now()->subYear(),
'role_title' => str_repeat('a', 125),
])->toArray();

$response = $this->actingAs($user)->putJson("api/authors/{$user->author->id}/employments/{$employment->id}", $data)->assertOk();

expect($response->json('data.role_title'))->toBe(str_repeat('a', 125));

});

0 comments on commit 5835aec

Please sign in to comment.