Skip to content

Commit

Permalink
Render /voting-in-the-uk as multi-page guide
Browse files Browse the repository at this point in the history
Undoes #1481

Reverting to the standard guide format now that the election period has
finished.
  • Loading branch information
sihugh committed Dec 16, 2019
1 parent 45c8cea commit 6ac647e
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 82 deletions.
2 changes: 0 additions & 2 deletions app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions app/presenters/content_item/parts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
5 changes: 0 additions & 5 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
51 changes: 0 additions & 51 deletions app/views/content_items/guide_single.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
Expand Down
18 changes: 0 additions & 18 deletions test/integration/guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6ac647e

Please sign in to comment.