From be3274aad79368dd99c6c4999040cad8b93ee5ff Mon Sep 17 00:00:00 2001 From: Edward Kerry Date: Tue, 14 Jan 2020 11:30:37 +0000 Subject: [PATCH 1/2] Allow new lines to show in change notes --- app/assets/stylesheets/components/_published-dates.scss | 4 ++++ app/views/components/_published-dates.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/components/_published-dates.scss b/app/assets/stylesheets/components/_published-dates.scss index 10b124218..ad8da1233 100644 --- a/app/assets/stylesheets/components/_published-dates.scss +++ b/app/assets/stylesheets/components/_published-dates.scss @@ -36,6 +36,10 @@ @include bold-16; } +.app-c-published-dates__change-note { + white-space: pre-line; +} + .app-c-published-dates--history { padding-top: govuk-spacing(2); border-top: 1px solid $border-colour; diff --git a/app/views/components/_published-dates.html.erb b/app/views/components/_published-dates.html.erb index e1aee3b90..3d118b08f 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] %>

  • <% end %> From 4b2a61fab572d0598caf785a65ae60616e2c05e0 Mon Sep 17 00:00:00 2001 From: Edward Kerry Date: Wed, 15 Jan 2020 12:14:18 +0000 Subject: [PATCH 2/2] Remove trailing and leading whitespace from change notes --- app/views/components/_published-dates.html.erb | 2 +- test/components/published_dates_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/components/_published-dates.html.erb b/app/views/components/_published-dates.html.erb index 3d118b08f..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"