FIX: 404 when visiting theme setting objects editor for theme component (#26733)

This commit fixes a bug where the server returns a 404 response code if
a user visits the URL to edit a objects type theme setting directly.
This commit is contained in:
Alan Guo Xiang Tan 2024-04-24 15:34:57 +08:00 committed by GitHub
parent 09f5af608f
commit 25bcee43c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -261,6 +261,7 @@ Discourse::Application.routes.draw do
get "components/:id" => "themes#index"
get "themes/:id/export" => "themes#export"
get "themes/:id/schema/:setting_name" => "themes#schema"
get "components/:id/schema/:setting_name" => "themes#schema"
# They have periods in their URLs often:
get "site_texts" => "site_texts#index"

View File

@ -1437,4 +1437,23 @@ RSpec.describe Admin::ThemesController do
end
end
end
describe "#schema" do
fab!(:theme)
fab!(:theme_component) { Fabricate(:theme, component: true) }
before { sign_in(admin) }
it "returns 200 when customizing a theme's setting of objects type" do
get "/admin/customize/themes/#{theme.id}/schema/some_setting_name"
expect(response.status).to eq(200)
end
it "returns 200 when customizing a theme component's setting of objects type" do
get "/admin/customize/components/#{theme_component.id}/schema/some_setting_name"
expect(response.status).to eq(200)
end
end
end