Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8132] Update actions and pages which set "noindex", "nofollow" crawler directives #8223

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update actions that set no crawl headers
Don't allow indexing of:
- New citation page
- New request page
- Similar requests page
- Request details page
- User profile wall
gbp committed Apr 30, 2024
commit cc8ec4db1b4424dba281e59ca0a3c0c733e06feb
1 change: 1 addition & 0 deletions app/controllers/citations_controller.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ class CitationsController < ApplicationController
before_action :authenticate
before_action :load_info_request_and_authorise
before_action :set_in_pro_area
before_action :set_no_crawl_headers

def new
@citation = current_user.citations.build
1 change: 1 addition & 0 deletions app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ class RequestController < ApplicationController
before_action :redirect_new_form_to_pro_version, only: [:select_authority, :new]
before_action :set_in_pro_area, only: [:select_authority, :show]
before_action :setup_results_pagination, only: [:list, :similar]
before_action :set_no_crawl_headers, only: [:new, :details, :similar]

helper_method :state_transitions_empty?

1 change: 1 addition & 0 deletions app/controllers/user_controller.rb
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ class UserController < ApplicationController
before_action :work_out_post_redirect, only: [ :signup ]
before_action :set_request_from_foreign_country, only: [ :signup ]
before_action :set_in_pro_area, only: [ :signup ]
before_action :set_no_crawl_headers, only: :wall

# Normally we wouldn't be verifying the authenticity token on these actions
# anyway as there shouldn't be a user_id in the session when the before
5 changes: 5 additions & 0 deletions spec/controllers/citations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -37,6 +37,11 @@
expect(response).to be_successful
end
end

it 'adds noindex header' do
action
expect(response.headers['X-Robots-Tag']).to eq 'noindex'
end
end

# when requester
15 changes: 15 additions & 0 deletions spec/controllers/request_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -734,6 +734,11 @@ def expect_hidden(hidden_template)
expect(response).to render_template('new_bad_contact')
end

it 'adds noindex header' do
get :new, params: { public_body_id: @body.id }
expect(response.headers['X-Robots-Tag']).to eq 'noindex'
end

context "the outgoing message includes an email address" do
context "there is no logged in user" do
it "displays a flash error message without escaping the HTML" do
@@ -1964,6 +1969,11 @@ def send_request
get :similar, params: { url_title: badger_request.url_title }
}.to raise_error(ActiveRecord::RecordNotFound)
end

it 'adds noindex header' do
get :similar, params: { url_title: badger_request.url_title }
expect(response.headers['X-Robots-Tag']).to eq 'noindex'
end
end

RSpec.describe RequestController, "when the site is in read_only mode" do
@@ -2041,6 +2051,11 @@ def send_request
}.to raise_error(ActiveRecord::RecordNotFound)
end
end

it 'adds noindex header' do
get :details, params: { url_title: info_request.url_title }
expect(response.headers['X-Robots-Tag']).to eq 'noindex'
end
end
end

6 changes: 6 additions & 0 deletions spec/controllers/user_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1351,4 +1351,10 @@ def make_request
get :wall, params: { url_name: user.url_name }
expect(assigns[:feed_results]).to be_empty
end

it 'adds noindex header' do
user = FactoryBot.create(:user)
get :wall, params: { url_name: user.url_name }
expect(response.headers['X-Robots-Tag']).to eq 'noindex'
end
end