A platform for community discussion. Free, open, simple.
FEATURE: add no_index header if robots is disabled
Sam Saffron676be3a85345
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 813af0c12f4..7abf1f36596 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -44,7 +44,7 @@ class ApplicationController < ActionController::Baseafter_action :perform_refresh_sessionafter_action :dont_cache_pageafter_action :conditionally_allow_site_embedding- after_action :add_noindex_header, if: -> { is_feed_request? }+ after_action :add_noindex_header, if: -> { is_feed_request? || !SiteSetting.allow_index_in_robots_txt }layout :set_layoutdiff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex 9f9b32ce2e3..b4d157d536f 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -1843,12 +1843,19 @@ RSpec.describe TopicsController doendit "is not included for normal topics" do- topic = Fabricate(:topic, visible: true)get "/t/#{topic.slug}/#{topic.id}.json"expect(response.headers['X-Robots-Tag']).to eq(nil)end+ it "is included when allow_index_in_robots_txt is set to false" do+ SiteSetting.allow_index_in_robots_txt = false++ get "/t/#{topic.slug}/#{topic.id}.json"++ expect(response.headers['X-Robots-Tag']).to eq('noindex')+ end+it "doesn't store an incoming link when there's no referer" doexpect {get "/t/#{topic.id}.json"