feat(organisation): add contact fields to model and API
Add contact_name, contact_email, phone, website columns. Wire the new fields through the Organisation model, update request validation, response resource, and the TypeScript Organisation interface. Needed by the upcoming dashboard + form-builder binding registry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -221,4 +221,65 @@ class OrganisationTest extends TestCase
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_org_admin_can_update_all_contact_fields(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$org = Organisation::factory()->create();
|
||||
$org->users()->attach($user, ['role' => 'org_admin']);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$response = $this->putJson("/api/v1/organisations/{$org->id}", [
|
||||
'contact_name' => 'Bert Hausmans',
|
||||
'contact_email' => 'bert@example.com',
|
||||
'phone' => '+31 6 12345678',
|
||||
'website' => 'https://example.com',
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson(['data' => [
|
||||
'contact_name' => 'Bert Hausmans',
|
||||
'contact_email' => 'bert@example.com',
|
||||
'phone' => '+31 6 12345678',
|
||||
'website' => 'https://example.com',
|
||||
]]);
|
||||
|
||||
$this->assertDatabaseHas('organisations', [
|
||||
'id' => $org->id,
|
||||
'contact_email' => 'bert@example.com',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_update_returns_422_for_invalid_contact_email(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$org = Organisation::factory()->create();
|
||||
$org->users()->attach($user, ['role' => 'org_admin']);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$response = $this->putJson("/api/v1/organisations/{$org->id}", [
|
||||
'contact_email' => 'not-an-email',
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertJsonValidationErrors(['contact_email']);
|
||||
}
|
||||
|
||||
public function test_update_returns_422_for_invalid_website_url(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$org = Organisation::factory()->create();
|
||||
$org->users()->attach($user, ['role' => 'org_admin']);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$response = $this->putJson("/api/v1/organisations/{$org->id}", [
|
||||
'website' => 'not a url',
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertJsonValidationErrors(['website']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user