diff --git a/app/Http/Controllers/Api/V1/Setting/SettingIndexController.php b/app/Http/Controllers/Api/V1/Setting/SettingIndexController.php index 46ce746..f8a174e 100644 --- a/app/Http/Controllers/Api/V1/Setting/SettingIndexController.php +++ b/app/Http/Controllers/Api/V1/Setting/SettingIndexController.php @@ -17,6 +17,7 @@ final class SettingIndexController extends Controller /** @var list */ private const PUBLIC_GROUPS = [ 'frontend', + 'currency', ]; public function __invoke(Request $request): JsonResponse diff --git a/tests/Feature/PublicSettingsApiTest.php b/tests/Feature/PublicSettingsApiTest.php index 278c3d4..9015c59 100644 --- a/tests/Feature/PublicSettingsApiTest.php +++ b/tests/Feature/PublicSettingsApiTest.php @@ -20,6 +20,22 @@ test('public settings requires allowed group', function (): void { ->assertJsonPath('code', ErrorCode::ClientHttpError->value); }); +test('public settings returns currency group', function (): void { + \App\Models\LotterySetting::query()->updateOrCreate( + ['setting_key' => 'currency.display_decimals'], + [ + 'group_name' => 'currency', + 'value_json' => 3, + 'description_zh' => '展示小数位', + ], + ); + + $this->getJson('/api/v1/settings?group=currency') + ->assertOk() + ->assertJsonPath('code', ErrorCode::Success->value) + ->assertJsonFragment(['key' => 'currency.display_decimals', 'value' => 3]); +}); + test('public settings returns frontend group only', function (): void { \App\Models\LotterySetting::query()->updateOrCreate( ['setting_key' => 'frontend.play_rules_html_zh'],