From 200072ecc485850f3d77ccdae4feb73a996adde1 Mon Sep 17 00:00:00 2001 From: Wieland Lindenthal Date: Fri, 27 Mar 2026 17:28:55 +0100 Subject: [PATCH] [#73511] Fix robots meta tag rendered as text instead of HTML element `content_tag(:meta, name:, content:)` treated the keyword arguments as text content rather than HTML attributes, producing visible JSON-like output on the page. Replace with `tag(:meta, ...)` which correctly renders a self-closing element with the proper attributes. Adds a view spec assertion to cover the rendered output. --- app/helpers/application_helper.rb | 2 +- spec/views/wiki/new.html.erb_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f7dbb97ed1..001f1e48d63 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -443,7 +443,7 @@ module ApplicationHelper # @param [optional, String] content the content of the ROBOTS tag. # defaults to no index, follow, and no archive def robot_exclusion_tag(content = "NOINDEX,FOLLOW,NOARCHIVE") - content_tag(:meta, name: "ROBOTS", content:) + tag(:meta, name: "ROBOTS", content:) end def permitted_params diff --git a/spec/views/wiki/new.html.erb_spec.rb b/spec/views/wiki/new.html.erb_spec.rb index 21a1d611ed7..90964703a16 100644 --- a/spec/views/wiki/new.html.erb_spec.rb +++ b/spec/views/wiki/new.html.erb_spec.rb @@ -72,4 +72,9 @@ RSpec.describe "wiki/new" do render assert_select "input", name: "page[parent_id]", value: "123", type: "hidden" end + + it "renders a robots exclusion meta tag in the header tags" do + render + expect(view.content_for(:header_tags)).to include('name="ROBOTS"', 'content="NOINDEX,FOLLOW,NOARCHIVE"') + end end