From 9e77fd8fc3707a9fe6285b11aaf0dc1b14080cf0 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 7 Sep 2018 10:03:30 -0400 Subject: [PATCH] FIX: wrong category links on subfolder install in rss feed for a category topic list --- app/controllers/list_controller.rb | 4 ++-- spec/requests/list_controller_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index a26aa6eff15..a5f297e6b1c 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -219,8 +219,8 @@ class ListController < ApplicationController discourse_expires_in 1.minute @title = "#{@category.name} - #{SiteSetting.title}" - @link = "#{Discourse.base_url}#{@category.url}" - @atom_link = "#{Discourse.base_url}#{@category.url}.rss" + @link = "#{Discourse.base_url_no_prefix}#{@category.url}" + @atom_link = "#{Discourse.base_url_no_prefix}#{@category.url}.rss" @description = "#{I18n.t('topics_in_category', category: @category.name)} #{@category.description}" @topic_list = TopicQuery.new(current_user).list_new_in_category(@category) diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb index e494bebf579..733ece50fd3 100644 --- a/spec/requests/list_controller_spec.rb +++ b/spec/requests/list_controller_spec.rb @@ -393,6 +393,15 @@ RSpec.describe ListController do expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end + + it "renders RSS in subfolder correctly" do + GlobalSetting.stubs(:relative_url_root).returns('/forum') + Discourse.stubs(:base_uri).returns("/forum") + get "/c/#{category.slug}.rss" + expect(response.status).to eq(200) + expect(response.body).to_not include("/forum/forum") + expect(response.body).to include("http://test.localhost/forum/c/#{category.slug}") + end end describe "category default views" do