Skip to content

Commit

Permalink
revert: reduce max character limit for role title and department name…
Browse files Browse the repository at this point in the history
… to 50
  • Loading branch information
vincentauger committed Dec 2, 2024
1 parent 5835aec commit 5126b79
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 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:125',
'department_name' => 'nullable|string|max:125',
'role_title' => 'nullable|string|max:50',
'department_name' => 'nullable|string|max:50',
'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:125',
'department_name' => 'nullable|string|max:125',
'role_title' => 'nullable|string|max:50',
'department_name' => 'nullable|string|max:50',
'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 <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
(val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]),
]"
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 <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
(val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]),
]"
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 <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
(val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]),
]"
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 <= 125 || t('common.validation.must-be-less-than-x-characters', [125]),
(val: string) => val.length <= 50 || t('common.validation.must-be-less-than-x-characters', [50]),
]"
class="q-mb-md"
:hint="t('orcid-employment-edit.department-name-hint')"
Expand Down
7 changes: 4 additions & 3 deletions tests/Feature/Models/AuthorEmployementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use App\Models\AuthorEmployment;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Support\Facades\Queue;

test('a user can list their author profile employements', function () {
$user = User::factory()->create();
Expand Down Expand Up @@ -120,7 +121,7 @@

});

test('adding a 125 char role title is valid', function () {
test('adding a 50 char role title is valid', function () {
$user = User::factory()->create();
$employment = AuthorEmployment::factory()->create([
'author_id' => $user->author->id,
Expand All @@ -132,11 +133,11 @@
'author_id' => $user->author->id,
'organization_id' => Organization::getDefaultOrganization()->id,
'start_date' => now()->subYear(),
'role_title' => str_repeat('a', 125),
'role_title' => str_repeat('a', 50),
])->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));
expect($response->json('data.role_title'))->toBe(str_repeat('a', 50));

});

0 comments on commit 5126b79

Please sign in to comment.