Skip to content

Commit

Permalink
Merge pull request #2144 from alphagov/brexit_descriptions
Browse files Browse the repository at this point in the history
Brexit child taxon descriptions
  • Loading branch information
hannako authored Jun 15, 2021
2 parents 7cb2385 + 32d1e9a commit 4be7e54
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 60 deletions.
28 changes: 0 additions & 28 deletions app/presenters/content_item/brexit_hub_page.rb

This file was deleted.

35 changes: 35 additions & 0 deletions app/presenters/content_item/brexit_taxons.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module ContentItem
module BrexitTaxons
BREXIT_BUSINESS_PAGE_CONTENT_ID = "91cd6143-69d5-4f27-99ff-a52fb0d51c78".freeze
BREXIT_BUSINESS_PAGE_PATH = "/guidance/brexit-guidance-for-businesses".freeze

BREXIT_CITIZEN_PAGE_CONTENT_ID = "6555e0bf-c270-4cf9-a0c5-d20b95fab7f1".freeze
BREXIT_CITIZEN_PAGE_PATH = "/guidance/brexit-guidance-for-individuals-and-families".freeze

def brexit_child_taxons
{
BREXIT_BUSINESS_PAGE_CONTENT_ID => {
nav_link: {
text: I18n.t("brexit.citizen_link"),
path: BREXIT_CITIZEN_PAGE_PATH,
track_label: "Guidance nav link",
},
track_category: "brexit-business-page",
},
BREXIT_CITIZEN_PAGE_CONTENT_ID => {
nav_link: {
text: I18n.t("brexit.business_link"),
path: BREXIT_BUSINESS_PAGE_PATH,
track_label: "Guidance nav link",

},
track_category: "brexit-citizen-page",
},
}
end

def brexit_child_taxon
brexit_child_taxons[content_item["content_id"]]
end
end
end
2 changes: 1 addition & 1 deletion app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ContentItemPresenter
include ContentItem::Withdrawable
include ContentItem::BrexitHubPage
include ContentItem::BrexitTaxons

attr_reader :content_item,
:requested_path,
Expand Down
28 changes: 14 additions & 14 deletions app/views/content_items/detailed_guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% brexit_link = @content_item.brexit_link %>
<% title_and_context = brexit_link ? { title: @content_item.title } : @content_item.title_and_context %>
<% brexit_child_taxon = @content_item.brexit_child_taxon %>
<% title_and_context = brexit_child_taxon ? { title: @content_item.title } : @content_item.title_and_context %>
<%= render 'govuk_publishing_components/components/title', title_and_context %>
</div>
<%= render 'shared/translations' %>
<div class="govuk-grid-column-two-thirds">
<% if brexit_link %>
<% if brexit_child_taxon %>
<div class="govuk-body-l govuk-!-margin-bottom-7">
<p class="govuk-body">
<%= I18n.t("brexit.heading_prefix") %>
<%= link_to(
brexit_link[:text],
brexit_link[:path],
brexit_child_taxon[:nav_link][:text],
brexit_child_taxon[:nav_link][:path],
class: "govuk-link",
data: {
track_action: brexit_link[:path],
track_category: brexit_link[:track_category],
track_label: "Guidance nav link",
track_action: brexit_child_taxon[:nav_link][:path],
track_category: brexit_child_taxon[:track_category],
track_label: brexit_child_taxon[:nav_link][:track_label],
module: 'gem-track-click',
}) %>.
</p>
Expand All @@ -34,7 +34,7 @@
</div>
</div>

<%= render 'shared/publisher_metadata_with_logo' unless brexit_link %>
<%= render 'shared/publisher_metadata_with_logo' unless brexit_child_taxon %>
<%= render 'shared/history_notice', content_item: @content_item %>
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>

Expand All @@ -46,10 +46,10 @@
<%= render "govuk_publishing_components/components/print_link", {
margin_top: 0,
margin_bottom: 6,
} unless brexit_link %>
} unless brexit_child_taxon %>

<% if brexit_link %>
<%= render partial: 'content_items/detailed_guide/brexit_links', locals: { brexit_link: brexit_link } %>
<% if brexit_child_taxon %>
<%= render partial: 'content_items/detailed_guide/brexit_sections', locals: { brexit_child_taxon: brexit_child_taxon } %>
<% else %>
<%= render 'govuk_publishing_components/components/govspeak', {} do %>
<%= raw(@content_item.govspeak_body[:content]) %>
Expand All @@ -61,13 +61,13 @@
published: @content_item.published,
last_updated: @content_item.updated,
history: @content_item.history
} unless brexit_link %>
} unless brexit_child_taxon %>
</div>
<% end %>
<%= render "govuk_publishing_components/components/print_link", {
margin_top: 0,
margin_bottom: 6,
} unless brexit_link %>
} unless brexit_child_taxon %>
</div>
<%= render 'shared/sidebar_navigation' %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
} %>
<% end %>
<% if section[:links].present? %>
<% track_category = brexit_link[:track_category] %>
<% links = section[:links].map do |link|
link_to(link[:text], link[:path], class: "govuk-link", data: {
track_action: link[:path],
track_category: track_category,
track_label: section[:title][:text] || "",
module: 'gem-track-click',
})
end
%>
<% links = section[:links].map do |link|
link_to(link[:text], link[:path], class: "govuk-link", data: {
track_action: link[:path],
track_category: brexit_child_taxon[:track_category],
track_label: section[:title][:text] || "",
module: 'gem-track-click',
})
end
%>
<%= render "govuk_publishing_components/components/list", {
items: links,
visible_counters: true,
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<% unless @do_not_show_breadcrumbs %>
<% if @content_item.try(:back_link) %>
<%= render 'govuk_publishing_components/components/back_link', href: @content_item.back_link %>
<% elsif @content_item.brexit_link %>
<%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/transition", title: "Brexit" } ] %>
<% elsif @content_item.brexit_child_taxon %>
<%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/brexit", title: "Brexit" } ] %>
<% else %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.content_item.parsed_content %>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions test/integration/detailed_guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
# renders description field as a custom link
assert_not page.has_text?(@content_item["description"])
link_text = "Brexit guidance for individuals and families"
assert page.has_link?(link_text, href: ContentItem::BrexitHubPage::BREXIT_CITIZEN_PAGE_PATH)
assert page.has_link?(link_text, href: ContentItem::BrexitTaxons::BREXIT_CITIZEN_PAGE_PATH)

setup_and_visit_brexit_child_taxon("citizen")

assert_not page.has_text?(@content_item["description"])
link_text = "Brexit guidance for businesses"
assert page.has_link?(link_text, href: ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_PATH)
assert page.has_link?(link_text, href: ContentItem::BrexitTaxons::BREXIT_BUSINESS_PAGE_PATH)

# adds GA tracking to the li links
track_action = find_link("Foreign travel advice")["data-track-action"]
Expand All @@ -126,7 +126,7 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
track_category = find_link("Brexit guidance for businesses")["data-track-category"]
track_label = find_link("Brexit guidance for businesses")["data-track-label"]

assert_equal ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_PATH, track_action
assert_equal ContentItem::BrexitTaxons::BREXIT_BUSINESS_PAGE_PATH, track_action
assert_equal "brexit-citizen-page", track_category
assert_equal "Guidance nav link", track_label
end
Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ def setup_and_visit_brexit_child_taxon(type = nil)
end

def brexit_citizen_id
ContentItem::BrexitHubPage::BREXIT_CITIZEN_PAGE_CONTENT_ID
ContentItem::BrexitTaxons::BREXIT_CITIZEN_PAGE_CONTENT_ID
end

def brexit_business_id
ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_CONTENT_ID
ContentItem::BrexitTaxons::BREXIT_BUSINESS_PAGE_CONTENT_ID
end

def brexit_body_content
Expand Down

0 comments on commit 4be7e54

Please sign in to comment.