From 6d442f1e40e813ac0c6e801da98807e520819d5b Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 20 Oct 2022 16:13:17 +0200 Subject: [PATCH 2/3] Always allow access to /robots.txt for Anonymous Previously, if logins were required, the /robots.txt was not accessible for Anonymous (i.e. search engines) as they were given a HTTP 401. --- app/controllers/welcome_controller.rb | 2 ++ test/integration/welcome_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index e526fe5b1c..0807c8232a 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,6 +20,8 @@ class WelcomeController < ApplicationController self.main_menu = false + skip_before_action :check_if_login_required, only: [:robots] + def index @news = News.latest User.current end diff --git a/test/integration/welcome_test.rb b/test/integration/welcome_test.rb index ffb3e240f7..1f46cd469c 100644 --- a/test/integration/welcome_test.rb +++ b/test/integration/welcome_test.rb @@ -42,4 +42,12 @@ def test_robots # closed projects are included in the list assert @response.body.match(%r{^Disallow: /projects/subproject1/issues\r?$}) end + + def test_robots_when_login_is_required + with_settings :login_required => '1' do + get '/robots.txt' + assert_response :success + assert_equal 'text/plain', @response.media_type + end + end end -- 2.34.0