From e607dd37670a43a2493bcc47a2e77d0105b17d06 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Mon, 6 May 2024 14:27:30 +1000 Subject: [PATCH] FIX: missing route for edit components (#26874) In this PR separate route for components was introduced https://github.com/discourse/discourse/pull/26644 However, the route to edit components was missed and it was 404 when reloaded. Meta: https://meta.discourse.org/t/missing-admin-theme-component-edit-route/306560 --- config/routes.rb | 1 + spec/requests/admin/themes_controller_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 34dc52d7445..006b1dfb377 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -259,6 +259,7 @@ Discourse::Application.routes.draw do get "themes/:id/:target/:field_name/edit" => "themes#index" get "themes/:id" => "themes#index" get "components/:id" => "themes#index" + get "components/:id/:target/:field_name/edit" => "themes#index" get "themes/:id/export" => "themes#export" get "themes/:id/schema/:setting_name" => "themes#schema" get "components/:id/schema/:setting_name" => "themes#schema" diff --git a/spec/requests/admin/themes_controller_spec.rb b/spec/requests/admin/themes_controller_spec.rb index e9d00fa1219..10834a649c6 100644 --- a/spec/requests/admin/themes_controller_spec.rb +++ b/spec/requests/admin/themes_controller_spec.rb @@ -478,6 +478,18 @@ RSpec.describe Admin::ThemesController do end end + it "allows themes and components to be edited" do + sign_in(admin) + theme = Fabricate(:theme, name: "Awesome Theme") + component = Fabricate(:theme, name: "Awesome component", component: true) + + get "/admin/customize/themes/#{theme.id}/common/scss/edit" + expect(response.status).to eq(200) + + get "/admin/customize/components/#{component.id}/common/scss/edit" + expect(response.status).to eq(200) + end + shared_examples "themes inaccessible" do it "denies access with a 404 response" do get "/admin/themes.json"