Skip to content

Commit

Permalink
Merge pull request #2496 from alphagov/remove-todo-comments
Browse files Browse the repository at this point in the history
Fetch title from manuals content item
  • Loading branch information
1pretz1 authored Jul 21, 2022
2 parents 360229d + f485c27 commit b1b8476
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
6 changes: 4 additions & 2 deletions app/presenters/content_item/manual_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ def breadcrumb
end

def manual_content_item
# TODO: Add the same tagging to a normal section as a manual for contextual breadcrumbs
# TODO: Add the manual published / public updated at to both manual sections (normal and HMRC)
@manual_content_item ||= Services.content_store.content_item(base_path)
end

def parsed_content_item
manual_content_item.parsed_content
end

def published
display_date(manual_content_item["first_published_at"])
end
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def initialize(content_item, requested_path, view_context)
@part_slug = requesting_a_part? ? requested_path.split("/").last : nil
end

def parsed_content_item
content_item.parsed_content
end

def requesting_a_part?
false
end
Expand Down
8 changes: 4 additions & 4 deletions app/presenters/hmrc_manual_section_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ def base_path
details["manual"]["base_path"]
end

def title
details["manual"]["title"]
end

def breadcrumbs
crumbs = manual_breadcrumbs.dup

Expand Down Expand Up @@ -85,6 +81,10 @@ def adjacent_siblings
[before.try(:last), after.try(:first)]
end

def manual
parent_base_path == base_path ? parent_for_section : manual_content_item
end

def parent_base_path
content_item_breadcrumbs.present? ? content_item_breadcrumbs.last["base_path"] : base_path
end
Expand Down
4 changes: 1 addition & 3 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
<%= render 'govuk_publishing_components/components/breadcrumbs',
breadcrumbs: [ { url: "/", title: "Home" } , { url: "/brexit", title: "Brexit" } ] %>
<% else %>
<!-- TODO: Remove manual_content_item after adding the same tagging to manual and hmrc manual section as the parent manual --!>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs',
content_item: @content_item.try(:manual_content_item) || @content_item.content_item.parsed_content %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.parsed_content_item %>
<% end %>
<% end %>

Expand Down
5 changes: 4 additions & 1 deletion test/presenters/hmrc_manual_section_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class PresentedHmrcManualSectionTest < HmrcManualSectionPresenterTestCase
end

test "presents manual title" do
manual = schema_item("vatgpb2000")["details"]["manual"]
manual_base_path = schema_item("vatgpb2000")["details"]["manual"]["base_path"]
manual = schema_item("vat-government-public-bodies", "hmrc_manual")
stub_content_store_has_item(manual_base_path, manual.to_json)

assert_equal manual["title"], presented_manual_section.title
end

Expand Down

0 comments on commit b1b8476

Please sign in to comment.