diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index fb95e76af0..a25fe7f442 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -26,7 +26,7 @@ def content_item end def content_item_slug - nil # set to override content item fetched from Content Store + request.path end def content_item_hash diff --git a/app/controllers/help_page_controller.rb b/app/controllers/help_page_controller.rb new file mode 100644 index 0000000000..4dd50e7ee7 --- /dev/null +++ b/app/controllers/help_page_controller.rb @@ -0,0 +1,2 @@ +class HelpPageController < ContentItemsController +end diff --git a/app/models/content_item.rb b/app/models/content_item.rb index 500659d61d..974ba6aaab 100644 --- a/app/models/content_item.rb +++ b/app/models/content_item.rb @@ -1,5 +1,5 @@ class ContentItem - attr_reader :content_store_response, :body, :image, :description, :document_type, :title, :base_path, :locale + attr_reader :content_store_response, :body, :image, :description, :document_type, :title, :base_path, :locale, :last_updated, :schema_name def initialize(content_store_response) @content_store_response = content_store_response @@ -10,6 +10,8 @@ def initialize(content_store_response) @title = content_store_response["title"] @base_path = content_store_response["base_path"] @locale = content_store_response["locale"] + @last_updated = content_store_response["public_updated_at"] + @schema_name = content_store_response["schema_name"] end delegate :to_h, to: :content_store_response diff --git a/app/views/help_page/show.html.erb b/app/views/help_page/show.html.erb new file mode 100644 index 0000000000..7ca2b1c10c --- /dev/null +++ b/app/views/help_page/show.html.erb @@ -0,0 +1,9 @@ +<% content_for :extra_head_content do %> + <%= render "govuk_publishing_components/components/machine_readable_metadata", { content_item: @content_item.to_h, schema: :article } %> +<% end %> + +<% if @content_item.base_path == '/help/cookie-details' %> + +<% end %> + +<%= render 'shared/body_with_related_links' %> diff --git a/app/views/shared/_body_with_related_links.html.erb b/app/views/shared/_body_with_related_links.html.erb new file mode 100644 index 0000000000..7062f839f8 --- /dev/null +++ b/app/views/shared/_body_with_related_links.html.erb @@ -0,0 +1,29 @@ +<% content_for :simple_header, true %> +
GOV.UK is the website for the UK government. It’s the best place to find government services and information.
" } + + let(:payload) do + { + base_path:, + format: "help_page", + title:, + details: { body: }, + } + end + + before do + stub_content_store_has_item(base_path, payload) + end + + it "displays the help page" do + visit base_path + + expect(page).to have_title("#{title} - GOV.UK") + expect(page).to have_css("h1", text: title) + expect(page).to have_text("GOV.UK is the website for the UK government. It’s the best place to find government services and information.") + end + + context "when visiting '/help/cookie-details'" do + let(:base_path) { "/help/cookie-details" } + let(:title) { "Details about cookies on GOV.UK" } + + it "sets noindex meta tag" do + visit base_path + + expect(page).to have_css('meta[name="robots"][content="noindex"]', visible: false) + end + + it "does not render with the single page notification button" do + visit base_path + + expect(page).not_to have_css(".gem-c-single-page-notification-button") + end + end +end diff --git a/spec/system/sessions_spec.rb b/spec/system/sessions_spec.rb index 7ba0e4d1d6..ee5fa85a07 100644 --- a/spec/system/sessions_spec.rb +++ b/spec/system/sessions_spec.rb @@ -6,7 +6,12 @@ include GdsApi::TestHelpers::EmailAlertApi include GovukPersonalisation::TestHelpers::Features + path = "/email/subscriptions/account/confirm" + before do + stub_request(:get, "http://content-store.dev.gov.uk/content#{path}") + .to_return(status: 200, body: { details: { body: "" }, links: {} }.to_json, headers: {}) + stub_content_store_has_item("/", schema: "special_route", links: {}) # The redirect test needs a route to actually exist to redirect to @@ -16,7 +21,7 @@ Rails.application.routes.disable_clear_and_finalize = true Rails.application.routes.draw do - get "/email/subscriptions/account/confirm", to: "homepage#index" + get path, to: "homepage#index" end end @@ -31,7 +36,7 @@ end it "Logs the user in and send them to a redirect path if supplied" do - redirect_path = "/email/subscriptions/account/confirm?frequency=immediately&return_to_url=true&topic_id=some-page-with-notifications" + redirect_path = "#{path}?frequency=immediately&return_to_url=true&topic_id=some-page-with-notifications" given_a_successful_login_attempt(redirect_path:) visit new_govuk_session_callback_path(code: "code", state: "state")