Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Actions/Workspace/CreateWorkspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions tests/Feature/Actions/Workspace/CreateWorkspaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down