Merge pull request #146 from dantaspaulo/fix/workspace-content-language-locale
fix(workspace): default content_language to the app locale, not 'en'
This commit is contained in:
commit
1284c46960
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