A platform for community discussion. Free, open, simple.
FIX: Show true content of robots.txt after restoring to default (#24980)
Osama Sayegh87883a196323
diff --git a/app/controllers/admin/robots_txt_controller.rb b/app/controllers/admin/robots_txt_controller.rbindex d2912f06927..6e1e788d9e5 100644--- a/app/controllers/admin/robots_txt_controller.rb+++ b/app/controllers/admin/robots_txt_controller.rb@@ -29,9 +29,9 @@ class Admin::RobotsTxtController < Admin::AdminControllerdef original_robots_txtif SiteSetting.allow_index_in_robots_txt?@robots_info = ::RobotsTxtController.fetch_default_robots_info- render_to_string "robots_txt/index"+ render_to_string "robots_txt/index", layout: falseelse- render_to_string "robots_txt/no_index"+ render_to_string "robots_txt/no_index", layout: falseendendenddiff --git a/spec/requests/admin/robots_txt_controller_spec.rb b/spec/requests/admin/robots_txt_controller_spec.rbindex 095491d1534..1c4a3967501 100644--- a/spec/requests/admin/robots_txt_controller_spec.rb+++ b/spec/requests/admin/robots_txt_controller_spec.rb@@ -101,11 +101,17 @@ RSpec.describe Admin::RobotsTxtController doit "resets robots.txt file to the default version" doSiteSetting.overridden_robots_txt = "overridden_content"- delete "/admin/customize/robots.json"+ SiteSetting.allowed_crawler_user_agents = "test-user-agent-154"++ delete "/admin/customize/robots.json", xhr: trueexpect(response.status).to eq(200)+json = response.parsed_bodyexpect(json["robots_txt"]).not_to include("overridden_content")+ expect(json["robots_txt"]).not_to include("</html>")+ expect(json["robots_txt"]).to include("User-agent: test-user-agent-154\n")expect(json["overridden"]).to eq(false)+expect(SiteSetting.overridden_robots_txt).to eq("")endend