Skip to content

A platform for community discussion. Free, open, simple.

FIX: category slug route was not working for subfolder setup

Arpit Jalan32d6286bea81
diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb
index 731fecad482..bd662ab1592 100644
--- a/app/controllers/list_controller.rb
+++ b/app/controllers/list_controller.rb
@@ -372,6 +372,10 @@ class ListController < ApplicationController
if current_slug != real_slug
url = request.fullpath.gsub(current_slug, real_slug)
+ if ActionController::Base.config.relative_url_root
+ url = url.sub(ActionController::Base.config.relative_url_root, "")
+ end
+
return redirect_to path(url), status: 301
end
diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb
index 3b54f45d465..1bcab4542d7 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -729,7 +729,15 @@ RSpec.describe ListController do
end
context "with subfolder" do
- it "redirects to URL containing the updated slug" do
+ it "main category redirects to URL containing the updated slug" do
+ set_subfolder "/forum"
+ get "/c/#{category.slug}"
+
+ expect(response.status).to eq(301)
+ expect(response).to redirect_to("/forum/c/#{category.slug}/#{category.id}")
+ end
+
+ it "sub-sub-category redirects to URL containing the updated slug" do
set_subfolder "/forum"
get "/c/hello/world/bye/#{subsubcategory.id}"