[#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.
This commit is contained in:
Wieland Lindenthal
2026-03-27 17:28:55 +01:00
committed by Oliver Günther
parent 7a3632a51e
commit 200072ecc4
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -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
+5
View File
@@ -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