From 49abcf965bfc9fc8728a3919dbd820c5bf59617a Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Mon, 10 Oct 2022 17:19:18 -0600 Subject: [PATCH] FEATURE: Hide Privacy Policy and TOS topics (#18533) * FEATURE: Hide Privacy Policy and TOS topics As a way to simplify new sites this change will hide the privacy policy and the TOS topics from the topic list. They can still be accessed and edited though. * add tests --- lib/topic_query.rb | 3 +++ spec/requests/list_controller_spec.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index ec75d182064..cc66f511784 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -438,6 +438,9 @@ class TopicQuery topics = topics.to_a + # These don't need to be shown in the topic list + topics = topics.reject { |t| [SiteSetting.privacy_topic_id, SiteSetting.tos_topic_id].include?(t[:id]) } + if options[:preload_posters] user_ids = [] topics.each do |ft| diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb index f105b1e8b08..30e948f88be 100644 --- a/spec/requests/list_controller_spec.rb +++ b/spec/requests/list_controller_spec.rb @@ -79,6 +79,19 @@ RSpec.describe ListController do expect(parsed["topic_list"]["topics"].length).to eq(1) end + it 'filters out privacy policy and tos topics' do + tos_topic = create_topic + SiteSetting.tos_topic_id = tos_topic.id + + pp_topic = create_topic + SiteSetting.privacy_topic_id = pp_topic.id + + get "/latest.json" + expect(response.status).to eq(200) + parsed = response.parsed_body + expect(parsed["topic_list"]["topics"].length).to eq(1) + end + it "shows correct title if topic list is set for homepage" do get "/latest"