FIX: add noindex header to user summary page.

FIX: add noindex header to user summary page.

diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 8d05417..34e936a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -349,6 +349,8 @@ class UsersController < ApplicationController
     @user = fetch_user_from_params(include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts))
     raise Discourse::NotFound unless guardian.can_see_profile?(@user)
 
+    response.headers['X-Robots-Tag'] = 'noindex'
+
     respond_to do |format|
       format.html do
         @restrict_fields = guardian.restrict_user_fields?(@user)
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 94765e9..5782bd1 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -2816,6 +2816,7 @@ describe UsersController do
       create_post(user: user)
 
       get "/u/#{user.username_lower}/summary.json"
+      expect(response.headers['X-Robots-Tag']).to eq('noindex')
       expect(response.status).to eq(200)
       json = response.parsed_body
 

GitHub sha: 4f4d8d68

Follow-up to FIX: add noindex header to user profile pages. · discourse/discourse@13f2298 · GitHub