- <%= render "components/important_metadata",
- items: @content_item.important_metadata,
- margin_bottom: true %>
+ <% if @content_item.important_metadata.any? %>
+ <%= content_tag :div, class: "important-metadata inverse-background" do %>
+ <%= render "govuk_publishing_components/components/metadata", {
+ inverse: true,
+ other: @content_item.important_metadata,
+ margin_bottom: 0,
+ } %>
+ <% end %>
+ <% end %>
<% if @content_item.release_date_changed? %>
- <%= render "components/important_metadata",
- title: t("statistics_announcement.changed_date"),
- items: {
- t("statistics_announcement.previous_date") => @content_item.previous_release_date,
- t("statistics_announcement.reason_for_change") => @content_item.release_date_change_reason,
- },
- margin_bottom: true
- %>
+ <%= content_tag :div, class: "inverse-background" do %>
+ <%= render "govuk_publishing_components/components/metadata", {
+ inverse: true,
+ other: {
+ t("statistics_announcement.previous_date") => @content_item.previous_release_date,
+ t("statistics_announcement.reason_for_change") => @content_item.release_date_change_reason,
+ },
+ margin_bottom: 0,
+ title: t("statistics_announcement.changed_date"),
+ } %>
+ <% end %>
<% end %>
diff --git a/config/initializers/dartsass.rb b/config/initializers/dartsass.rb
index e2cadc570..7611ffd9b 100644
--- a/config/initializers/dartsass.rb
+++ b/config/initializers/dartsass.rb
@@ -5,7 +5,6 @@
"components/_contents-list-with-body.scss" => "components/_contents-list-with-body.css",
"components/_download-link.scss" => "components/_download-link.css",
"components/_figure.scss" => "components/_figure.css",
- "components/_important-metadata.scss" => "components/_important-metadata.css",
"components/_published-dates.scss" => "components/_published-dates.css",
"views/_guide.scss" => "views/_guide.css",
"views/_html-publication.scss" => "views/_html-publication.css",
diff --git a/test/components/important_metadata_test.rb b/test/components/important_metadata_test.rb
deleted file mode 100644
index 660c5d989..000000000
--- a/test/components/important_metadata_test.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require "component_test_helper"
-
-class ImportantMetadataTest < ComponentTestCase
- def component_name
- "important_metadata"
- end
-
- test "does not render metadata when no data is given" do
- assert_empty render_component({})
- end
-
- test "does not render when an 'other' object is provided without any values" do
- assert_empty render_component(other: { From: [] })
- assert_empty render_component(other: { a: false, b: "", c: [], d: {}, e: nil })
- end
-
- test "renders a title when a title is provided" do
- render_component(
- title: "The release date has been changed",
- items: {
- "Release Date": "14 October 2016",
- },
- )
-
- assert_select ".app-c-important-metadata__title", text: "The release date has been changed"
- end
-
- test "renders metadata link pairs from data it is given" do
- render_component(items: {
- "Opened": "14 October 2016",
- "Case type": ['
Mergers'],
- "Case state": ['
Open'],
- "Market sector": ['
Motor industry'],
- "Outcome": ['
Mergers - phase 2 clearance with remedies'],
- })
-
- assert_select ".app-c-important-metadata dt", text: "Opened:"
- assert_select ".app-c-important-metadata dd", text: "14 October 2016"
- assert_select ".app-c-important-metadata dt", text: "Case type:"
- assert_select ".app-c-important-metadata dd", text: "Mergers"
- assert_select ".app-c-important-metadata dd a[href='https://www.gov.uk/cma-cases?case_type%5B%5D=mergers']",
- text: "Mergers"
- assert_select ".app-c-important-metadata dt", text: "Case state:"
- assert_select ".app-c-important-metadata dd", text: "Open"
- assert_select ".app-c-important-metadata dd a[href='https://www.gov.uk/cma-cases?case_state%5B%5D=open']",
- text: "Open"
- assert_select ".app-c-important-metadata dt", text: "Market sector:"
- assert_select ".app-c-important-metadata dd", text: "Motor industry"
- assert_select ".app-c-important-metadata dd a[href='https://www.gov.uk/cma-cases?market_sector%5B%5D=motor-industry']",
- text: "Motor industry"
- assert_select ".app-c-important-metadata dt", text: "Outcome:"
- assert_select ".app-c-important-metadata dd", text: "Mergers - phase 2 clearance with remedies"
- assert_select ".app-c-important-metadata dd a[href='https://www.gov.uk/cma-cases?outcome_type%5B%5D=mergers-phase-2-clearance-with-remedies']",
- text: "Mergers - phase 2 clearance with remedies"
- end
-end
diff --git a/test/integration/fatality_notice_test.rb b/test/integration/fatality_notice_test.rb
index 0a8e113e7..5bcec6ac2 100644
--- a/test/integration/fatality_notice_test.rb
+++ b/test/integration/fatality_notice_test.rb
@@ -24,7 +24,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
from: {
"Ministry of Defence": "/government/organisations/ministry-of-defence",
},
- })
+ }, context_selector: ".metadata-column")
assert_has_important_metadata(
"Field of operation": { "Zululand": "/government/fields-of-operation/zululand" },
@@ -60,7 +60,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
assert_has_metadata({ from: {
"Ministry of Defence": "/government/organisations/ministry-of-defence",
"The Rt Hon Sir Eric Pickles MP": "/government/people/eric-pickles",
- } })
+ } }, context_selector: ".metadata-column")
end
test "fatality notice with withdrawn notice" do
diff --git a/test/integration/publication_test.rb b/test/integration/publication_test.rb
index cb8cfa824..f67875101 100644
--- a/test/integration/publication_test.rb
+++ b/test/integration/publication_test.rb
@@ -25,7 +25,7 @@ class PublicationTest < ActionDispatch::IntegrationTest
"Environment Agency": "/government/organisations/environment-agency",
"The Rt Hon Sir Eric Pickles MP": "/government/people/eric-pickles",
},
- })
+ }, context_selector: ".metadata-column")
assert_has_structured_data(page, "Article")
diff --git a/test/integration/specialist_document_test.rb b/test/integration/specialist_document_test.rb
index fd129e0db..1acca926b 100644
--- a/test/integration/specialist_document_test.rb
+++ b/test/integration/specialist_document_test.rb
@@ -24,7 +24,7 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest
"Air Accidents Investigation Branch":
"/government/organisations/air-accidents-investigation-branch",
},
- })
+ }, context_selector: ".metadata-column")
end
test "renders published and updated in metadata" do
diff --git a/test/integration/speech_test.rb b/test/integration/speech_test.rb
index 1fd446959..545ddd261 100644
--- a/test/integration/speech_test.rb
+++ b/test/integration/speech_test.rb
@@ -27,7 +27,7 @@ class SpeechTest < ActionDispatch::IntegrationTest
"The Rt Hon Andrea Leadsom MP": "/government/people/andrea-leadsom",
},
published: "8 March 2016",
- })
+ }, context_selector: ".metadata-column")
assert_has_important_metadata(
"Delivered on":
diff --git a/test/integration/statistical_data_set_test.rb b/test/integration/statistical_data_set_test.rb
index 9c97372f8..6744c4509 100644
--- a/test/integration/statistical_data_set_test.rb
+++ b/test/integration/statistical_data_set_test.rb
@@ -15,7 +15,8 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest
assert_has_metadata({
published: "13 December 2012",
from: { "Department for Transport": "/government/organisations/department-for-transport" },
- })
+ }, context_selector: ".metadata-column")
+
assert_footer_has_published_dates("Published 13 December 2012")
end
diff --git a/test/integration/statistics_announcement_test.rb b/test/integration/statistics_announcement_test.rb
index f240444ea..10182b502 100644
--- a/test/integration/statistics_announcement_test.rb
+++ b/test/integration/statistics_announcement_test.rb
@@ -17,7 +17,7 @@ class StatisticsAnnouncementTest < ActionDispatch::IntegrationTest
assert page.has_text?(@content_item["description"])
assert page.has_css?('img[alt="Accredited official statistics"]')
- within ".app-c-important-metadata" do
+ within ".important-metadata .gem-c-metadata" do
assert page.has_text?(:all, "Release date: January 2016 (provisional)")
end
end
@@ -45,7 +45,7 @@ class StatisticsAnnouncementTest < ActionDispatch::IntegrationTest
assert page.has_text?(@content_item["description"])
assert page.has_text?(:all, "Release date: 20 January 2016 9:30am (confirmed)")
- within ".release-date-changed .app-c-important-metadata" do
+ within ".release-date-changed .gem-c-metadata" do
assert page.has_text?("The release date has been changed")
assert page.has_text?("Previous date")
assert page.has_text?("19 January 2016 9:30am")
diff --git a/test/test_helper.rb b/test/test_helper.rb
index a54c7c71f..f036dc4d0 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -105,8 +105,8 @@ def assert_has_publisher_metadata_other(any_args)
assert_has_metadata(any_args)
end
- def assert_has_metadata(any_args, extra_metadata_classes: nil)
- within ".gem-c-metadata#{extra_metadata_classes}" do
+ def assert_has_metadata(any_args, context_selector: nil, extra_metadata_classes: nil)
+ within "#{context_selector} .gem-c-metadata#{extra_metadata_classes}" do
any_args.each_value do |value|
value = { value => nil } if value.is_a?(String)
value.each do |text, href|
@@ -138,9 +138,9 @@ def assert_has_metadata_local(metadata, term_selector, definition_selector)
end
def assert_has_important_metadata(metadata)
- within(".app-c-important-metadata") do
+ within(".important-metadata .gem-c-metadata") do
assert_has_metadata_local(
- metadata, ".app-c-important-metadata__term", ".app-c-important-metadata__definition"
+ metadata, ".gem-c-metadata__term", ".gem-c-metadata__definition"
)
end
end