Skip to content

Commit

Permalink
Merge pull request #2446 from alphagov/use-govuk-design-system-inform…
Browse files Browse the repository at this point in the history
…ation-banner-for-historical-editions

Use govuk design system information banner for historical editions and html attachments
  • Loading branch information
davidgisbey authored May 31, 2022
2 parents d4511a9 + 9c9e46a commit ed63e5b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/presenters/html_publication_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class HtmlPublicationPresenter < ContentItemPresenter
include ContentItem::Body
include ContentItem::OrganisationBranding
include ContentItem::ContentsList
include ContentItem::Political

def isbn
content_item["details"]["isbn"]
Expand Down
1 change: 1 addition & 0 deletions app/views/content_items/html_publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<p class="publication-header__last-changed"><%= @content_item.last_changed %></p>
<% end %>

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

<div
Expand Down
4 changes: 3 additions & 1 deletion app/views/shared/_history_notice.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% if content_item.historically_political? %>
<%= render 'components/banner', text: t("shared.historically_political", government: content_item.publishing_government) %>
<%= render "govuk_publishing_components/components/notice", {
title: t("shared.historically_political", government: content_item.publishing_government),
} %>
<% end %>
2 changes: 1 addition & 1 deletion test/integration/detailed_guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
test "historically political detailed guide" do
setup_and_visit_content_item("political_detailed_guide")

within ".app-c-banner" do
within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/document_collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest
test "historically political collection" do
setup_and_visit_content_item("document_collection_political")

within ".app-c-banner" do
within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/integration/html_publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def assert_has_component_organisation_logo_with_brand(brand, index = 1)
end
end

test "historically political html publication" do
setup_and_visit_html_publication("published_with_history_mode")

within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end

test "withdrawn html publication" do
content_item = GovukSchemas::Example.find("html_publication", example_name: "prime_ministers_office")
content_item["withdrawn_notice"] = {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/news_article_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class NewsArticleTest < ActionDispatch::IntegrationTest
test "renders history notice" do
setup_and_visit_content_item("news_article_history_mode")

within ".app-c-banner" do
within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PublicationTest < ActionDispatch::IntegrationTest
test "historically political publication" do
setup_and_visit_content_item("political_publication")

within ".app-c-banner" do
within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/statistical_data_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest
test "historically political statistical data set" do
setup_and_visit_content_item("statistical_data_set_political")

within ".app-c-banner" do
within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/world_location_news_article_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class WorldLocationNewsArticleTest < ActionDispatch::IntegrationTest

test "renders history notice" do
setup_and_visit_content_item("world_location_news_article_history_mode")
within ".app-c-banner" do
within ".govuk-notification-banner__content" do
assert page.has_text?("This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government")
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/presenters/html_publication_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def schema_name
"html_publication"
end

test "includes political" do
assert presented_item("published").is_a?(ContentItem::Political)
end

test "presents the basic details of a content item" do
assert_equal schema_item("published")["schema_name"], presented_item("published").schema_name
assert_equal schema_item("published")["links"]["parent"][0]["document_type"], presented_item("published").format_sub_type
Expand Down

0 comments on commit ed63e5b

Please sign in to comment.