diff --git a/app/assets/stylesheets/components/_published-dates.scss b/app/assets/stylesheets/components/_published-dates.scss index 3187e1e55..cd881caa0 100644 --- a/app/assets/stylesheets/components/_published-dates.scss +++ b/app/assets/stylesheets/components/_published-dates.scss @@ -25,6 +25,10 @@ @include govuk-font(16, $weight: bold); } +.app-c-published-dates__change-note { + white-space: pre-line; +} + .app-c-published-dates--history { padding-top: govuk-spacing(2); border-top: 1px solid $govuk-border-colour; diff --git a/app/views/components/_published-dates.html.erb b/app/views/components/_published-dates.html.erb index e1aee3b90..7ae6a26b4 100644 --- a/app/views/components/_published-dates.html.erb +++ b/app/views/components/_published-dates.html.erb @@ -26,7 +26,7 @@ <% history.each do |change| %>
  • - <%= change[:note] %> +

    <%= change[:note].strip %>

  • <% end %> diff --git a/test/components/published_dates_test.rb b/test/components/published_dates_test.rb index c14110e28..588e5aa7e 100644 --- a/test/components/published_dates_test.rb +++ b/test/components/published_dates_test.rb @@ -35,6 +35,16 @@ def component_name assert_select ".app-c-published-dates--history .app-c-published-dates__change-date", text: "23 August 2013" end + test "strips leading and trailing whitespace from note text" do + render_component( + published: "1st November 2000", + last_updated: "15th July 2015", + history: [display_time: "23 August 2013", note: "Updated with new data"], + ) + assert_select ".app-c-published-dates__change-history#full-history" + assert_select ".app-c-published-dates--history .app-c-published-dates__change-note", text: /^\S/ + end + test "only adds history id when passed page history" do render_component(published: "1st November 2000") assert_select "#history", false, "should only render history id if passed history item"