A platform for community discussion. Free, open, simple.
FIX: add X-Robots-Tag header for check_xhr-covered GET actions, too (#9868)
Artem Vasiliev12544c02c103
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 2f2b8a9694f..a0f0a566305 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -39,12 +39,12 @@ class ApplicationController < ActionController::Basebefore_action :redirect_to_login_if_requiredbefore_action :block_if_requires_loginbefore_action :preload_json+ before_action :add_noindex_header, if: -> { is_feed_request? || !SiteSetting.allow_index_in_robots_txt }before_action :check_xhrafter_action :add_readonly_headerafter_action :perform_refresh_sessionafter_action :dont_cache_pageafter_action :conditionally_allow_site_embedding- after_action :add_noindex_header, if: -> { is_feed_request? || !SiteSetting.allow_index_in_robots_txt }layout :set_layoutdiff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rbindex 11eb7eb0e45..eb6b4d56d56 100644--- a/spec/requests/groups_controller_spec.rb+++ b/spec/requests/groups_controller_spec.rb@@ -176,6 +176,12 @@ describe GroupsController do)end+ it 'should return correct X-Robots-Tag header when allow_index_in_robots_txt is set to false' do+ SiteSetting.allow_index_in_robots_txt = false+ get "/groups"+ expect(response.headers['X-Robots-Tag']).to eq('noindex, nofollow')+ end+context 'viewing groups of another user' dodescribe 'when an invalid username is given' doit 'should return the right response' do