From 6ac647ef6b7f4220ec86fe38c57435eb635fc7e3 Mon Sep 17 00:00:00 2001 From: Simon Hughesdon Date: Mon, 16 Dec 2019 16:32:58 +0000 Subject: [PATCH] Render /voting-in-the-uk as multi-page guide Undoes https://github.com/alphagov/government-frontend/pull/1481 Reverting to the standard guide format now that the election period has finished. --- app/controllers/content_items_controller.rb | 2 - app/presenters/content_item/parts.rb | 4 +- app/presenters/content_item_presenter.rb | 5 -- app/views/content_items/guide_single.html.erb | 51 ------------------- config/routes.rb | 3 -- test/integration/guide_test.rb | 18 ------- 6 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 app/views/content_items/guide_single.html.erb diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb index 7acaff8e9..796028460 100644 --- a/app/controllers/content_items_controller.rb +++ b/app/controllers/content_items_controller.rb @@ -84,8 +84,6 @@ def format_banner_links(links, type) end def content_item_template - return "guide_single" if @content_item.render_guide_as_single_page? - @content_item.schema_name end diff --git a/app/presenters/content_item/parts.rb b/app/presenters/content_item/parts.rb index e44bc4c6b..da0f12f7c 100644 --- a/app/presenters/content_item/parts.rb +++ b/app/presenters/content_item/parts.rb @@ -61,9 +61,7 @@ def previous_and_next_navigation def part_link_elements parts.map do |part| - if render_guide_as_single_page? - { href: "##{part['slug']}", text: part["title"] } - elsif part["slug"] != current_part["slug"] + if part["slug"] != current_part["slug"] { href: part["full_path"], text: part["title"] } else { href: part["full_path"], text: part["title"], active: true } diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index 6f5adf6c5..35da16732 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -80,11 +80,6 @@ def cache_control_public? !content_item.cache_control.private? end - def render_guide_as_single_page? - # /voting-in-the-uk - content_id == "9315bc67-33e7-42e9-8dea-e022f56dabfa" - end - private def display_date(timestamp, format = "%-d %B %Y") diff --git a/app/views/content_items/guide_single.html.erb b/app/views/content_items/guide_single.html.erb deleted file mode 100644 index e0030c800..000000000 --- a/app/views/content_items/guide_single.html.erb +++ /dev/null @@ -1,51 +0,0 @@ -<% content_for :extra_head_content do %> - <%= machine_readable_metadata( - schema: :article, - canonical_url: @content_item.canonical_url, - body: @content_item.current_part_body - ) %> -<% end %> - - - -<% content_for :simple_header, true %> - -
-
- <%= render 'govuk_publishing_components/components/title', { title: @content_item.content_title } %> - - <% if @content_item.show_guide_navigation? %> - - <% end %> -
- -
- <% if @content_item.has_parts? %> - - <% @content_item.parts.each_with_index do |part, index| %> -
"> - <%= render "govuk_publishing_components/components/heading", { - text: part["title"], - id: part["slug"], - heading_level: 1, - border_top: index.zero? ? 0 : 2, - padding: true - } %> - - <%= render 'govuk_publishing_components/components/govspeak', - content: part["body"].html_safe, - direction: page_text_direction, - disable_youtube_expansions: true %> -
- <% end %> - <% end %> -
- - <%= render 'shared/sidebar_navigation' %> -
- -<%= render 'shared/footer_navigation' %> diff --git a/config/routes.rb b/config/routes.rb index fcfcacce2..0eca6af76 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,9 +11,6 @@ get "healthcheck", to: proc { [200, {}, [""]] } - # Testing guides as a single page so we redirect parts to the default page - get "/voting-in-the-uk/:chapter", to: redirect("/voting-in-the-uk#%{chapter}") - get "*path/:variant" => "content_items#show", constraints: { variant: /print/, diff --git a/test/integration/guide_test.rb b/test/integration/guide_test.rb index 08777017d..633050311 100644 --- a/test/integration/guide_test.rb +++ b/test/integration/guide_test.rb @@ -112,24 +112,6 @@ class GuideTest < ActionDispatch::IntegrationTest assert_nil faq_schema end - test "voting in the UK guide shows all chapters on a single page" do - content_item = setup_and_visit_voting_guide - part_titles = content_item["details"]["parts"].map { |part| part["title"] } - - part_titles.each do |part_title| - assert page.has_css? "h1", text: part_title - end - end - - def setup_and_visit_voting_guide - @content_item = get_content_example("guide").tap do |item| - item["base_path"] = "/voting-in-the-uk" - item["content_id"] = "9315bc67-33e7-42e9-8dea-e022f56dabfa" - content_store_has_item(item["base_path"], item.to_json) - visit_with_cachebust(item["base_path"]) - end - end - def setup_and_visit_part_in_guide @content_item = get_content_example("guide").tap do |item| chapter_path = "#{item['base_path']}/key-stage-1-and-2"