Skip to content

Commit a073f71

Browse files
committed
WIP add hide_from_search_engines method
- relies upon publication presenter
1 parent 784a664 commit a073f71

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
class HtmlPublicationPresenter < ContentItemPresenter
2+
def hide_from_search_engines?
3+
PublicationPresenter::PATHS_TO_HIDE.any? { |path| content_item.base_path.start_with?(path) }
4+
end
25
end

app/views/html_publication/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
content_item: content_item.to_h
77
%>
88

9-
<% if content_item.hide_from_search_engines? %>
9+
<% if @presenter.hide_from_search_engines? %>
1010
<meta name="robots" content="noindex">
1111
<% end %>
1212
<% end %>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
RSpec.describe HtmlPublicationPresenter do
2+
subject(:html_publication_presenter) { described_class.new(HtmlPublication.new(content_store_response)) }
3+
4+
let(:content_store_response) { GovukSchemas::Example.find("html_publication", example_name: "long_form_and_automatically_numbered_headings") }
5+
6+
describe "#hide_from_search_engines?" do
7+
it "returns false" do
8+
expect(html_publication_presenter.hide_from_search_engines?).to be false
9+
end
10+
11+
context "when the page is in the hide list" do
12+
let(:content_store_response) do
13+
GovukSchemas::Example.find("html_publication", example_name: "long_form_and_automatically_numbered_headings").merge({
14+
"base_path" => "/government/publications/govuk-app-testing-privacy-notice-how-we-use-your-data",
15+
})
16+
end
17+
18+
it "returns true" do
19+
expect(html_publication_presenter.hide_from_search_engines?).to be true
20+
end
21+
end
22+
end
223
end

0 commit comments

Comments
 (0)