Skip to content

Commit

Permalink
Render history notice for historically_political html attachments
Browse files Browse the repository at this point in the history
This does the work to ensure that if a html attachment is historically
political then the history notice banner is rendered like it is for
various other document types such as News Articles.
  • Loading branch information
davidgisbey committed May 31, 2022
1 parent 4d08d7d commit 9c9e46a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 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
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
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 9c9e46a

Please sign in to comment.