FEATURE: add noindex header to badges, groups, and /my pages (#9736)

This commit is contained in:
Joshua Rosenfeld 2020-05-11 01:05:42 -04:00 committed by GitHub
parent 29842e682b
commit 07b728c5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,7 @@
class BadgesController < ApplicationController class BadgesController < ApplicationController
skip_before_action :check_xhr, only: [:index, :show] skip_before_action :check_xhr, only: [:index, :show]
after_action :add_noindex_header
def index def index
raise Discourse::NotFound unless SiteSetting.enable_badges raise Discourse::NotFound unless SiteSetting.enable_badges

View File

@ -15,6 +15,7 @@ class GroupsController < ApplicationController
skip_before_action :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed] skip_before_action :preload_json, :check_xhr, only: [:posts_feed, :mentions_feed]
skip_before_action :check_xhr, only: [:show] skip_before_action :check_xhr, only: [:show]
after_action :add_noindex_header
TYPE_FILTERS = { TYPE_FILTERS = {
my: Proc.new { |groups, user| my: Proc.new { |groups, user|

View File

@ -48,7 +48,7 @@ class UsersController < ApplicationController
:admin_login, :admin_login,
:confirm_admin] :confirm_admin]
after_action :add_noindex_header, only: [:show] after_action :add_noindex_header, only: [:show, :my_redirect]
def index def index
end end

View File

@ -17,6 +17,7 @@ describe BadgesController do
expect(response.status).to eq(200) expect(response.status).to eq(200)
parsed = response.parsed_body parsed = response.parsed_body
expect(parsed["badges"].length).to eq(Badge.enabled.count) expect(parsed["badges"].length).to eq(Badge.enabled.count)
expect(response.headers['X-Robots-Tag']).to eq('noindex')
end end
end end

View File

@ -364,6 +364,7 @@ describe GroupsController do
expect(body['group']['id']).to eq(group.id) expect(body['group']['id']).to eq(group.id)
expect(body['extras']["visible_group_names"]).to eq([group.name]) expect(body['extras']["visible_group_names"]).to eq([group.name])
expect(response.headers['X-Robots-Tag']).to eq('noindex')
end end
context 'as an admin' do context 'as an admin' do

View File

@ -2433,6 +2433,7 @@ describe UsersController do
it "redirects if the user is not logged in" do it "redirects if the user is not logged in" do
get "/my/wat.json" get "/my/wat.json"
expect(response).to be_redirect expect(response).to be_redirect
expect(response.headers['X-Robots-Tag']).to eq('noindex')
end end
context "when the user is logged in" do context "when the user is logged in" do