FIX: Respect query params for latest.rss (#10350)

Apparently latest.json and latest.rss are not routed to the same
controller methods. This change allows for any passed in query
parameters to actually be applied to the rss route.

This came in as a request on meta:

https://meta.discourse.org/t/-/155812/6
This commit is contained in:
Blake Erickson 2020-08-03 01:03:58 -06:00 committed by GitHub
parent ea7e7900a4
commit 4dae9d458b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -176,11 +176,13 @@ class ListController < ApplicationController
def latest_feed
discourse_expires_in 1.minute
options = { order: 'created' }.merge(build_topic_list_options)
@title = "#{SiteSetting.title} - #{I18n.t("rss_description.latest")}"
@link = "#{Discourse.base_url}/latest"
@atom_link = "#{Discourse.base_url}/latest.rss"
@description = I18n.t("rss_description.latest")
@topic_list = TopicQuery.new(nil, order: 'created').list_latest
@topic_list = TopicQuery.new(nil, options).list_latest
render 'list', formats: [:rss]
end

View File

@ -324,6 +324,13 @@ RSpec.describe ListController do
expect(response.headers['X-Robots-Tag']).to eq('noindex')
end
it 'renders latest RSS with query params' do
get "/latest.rss?status=closed"
expect(response.status).to eq(200)
expect(response.media_type).to eq('application/rss+xml')
expect(response.body).to_not include("<item>")
end
it 'renders links correctly with subfolder' do
set_subfolder "/forum"
_post = Fabricate(:post, topic: topic, user: user)