fix(workspace): default content_language to the app locale, not 'en'
When a workspace is created without an explicit content_language, `data_get($data, 'content_language')` returns null, array_filter drops the key, and the column falls back to its DB default of 'en'. So AI content and notifications came out in English even when the app was running in another locale. Default to `app()->getLocale()` instead, so a new workspace inherits the user's current language. An explicit content_language still wins.
This commit is contained in:
parent
bfa018a4cd
commit
7dab106f06
2 changed files with 23 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ public static function execute(User $user, array $data): Workspace
|
|||
'brand_color' => data_get($data, 'brand_color'),
|
||||
'background_color' => data_get($data, 'background_color'),
|
||||
'text_color' => data_get($data, 'text_color'),
|
||||
'content_language' => data_get($data, 'content_language'),
|
||||
'content_language' => data_get($data, 'content_language', app()->getLocale()),
|
||||
], static fn ($value): bool => $value !== null);
|
||||
|
||||
$workspace = DB::transaction(function () use ($user, $attributes): Workspace {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,28 @@
|
|||
expect($member?->pivot->role)->toBe(Role::Admin->value);
|
||||
});
|
||||
|
||||
test('CreateWorkspace inherits the app locale as content_language when none is given', function () {
|
||||
app()->setLocale('pt-BR');
|
||||
|
||||
$account = Account::factory()->create();
|
||||
$user = User::factory()->create(['account_id' => $account->id]);
|
||||
|
||||
$workspace = CreateWorkspace::execute($user, ['name' => 'Acme']);
|
||||
|
||||
expect($workspace->content_language)->toBe('pt-BR');
|
||||
});
|
||||
|
||||
test('CreateWorkspace keeps an explicit content_language over the app locale', function () {
|
||||
app()->setLocale('pt-BR');
|
||||
|
||||
$account = Account::factory()->create();
|
||||
$user = User::factory()->create(['account_id' => $account->id]);
|
||||
|
||||
$workspace = CreateWorkspace::execute($user, ['name' => 'Acme', 'content_language' => 'es']);
|
||||
|
||||
expect($workspace->content_language)->toBe('es');
|
||||
});
|
||||
|
||||
test('CreateWorkspace ignores unknown extra keys like logo_url', function () {
|
||||
$account = Account::factory()->create();
|
||||
$user = User::factory()->create(['account_id' => $account->id]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue