DEV: Move config area site setting fetch into new controller (#28136)

Followup 4aea12fdcb21216a528451c0f8803e02dff24998

In certain config areas (like About) we want to be able
to fetch specific site settings by name. In this case,
sometimes we need to be able to fetch hidden settings,
in cases where a config area is still experimental.

Splitting out a different endpoint for this purpose
allows us to be stricter with what we return for config
areas without affecting the main site settings UI, revealing
hidden settings before they are ready.
This commit is contained in:
Martin Brennan
2024-07-30 15:41:28 +10:00
committed by GitHub
parent 284aa1da22
commit 2d5f323ca3
6 changed files with 103 additions and 29 deletions

View File

@ -21,23 +21,14 @@ RSpec.describe Admin::SiteSettingsController do
expect(locale.length).to eq(1)
end
describe "the filter_names param" do
it "only returns settings that are specified in the filter_names param" do
get "/admin/site_settings.json",
params: {
filter_names: %w[title site_description notification_email],
}
expect(response.status).to eq(200)
json = response.parsed_body
expect(json["site_settings"].size).to eq(3)
expect(json["site_settings"].map { |s| s["setting"] }).to contain_exactly(
"title",
"site_description",
"notification_email",
)
end
it "does not return hidden site settings" do
get "/admin/site_settings.json"
expect(response.status).to eq(200)
expect(
response.parsed_body["site_settings"].find do |s|
s["setting"] == "set_locale_from_cookie"
end,
).to be_nil
end
end