Skip to content

Commit

Permalink
Merge pull request #1619 from alphagov/add_line_breaks_to_change_notes
Browse files Browse the repository at this point in the history
Allow new lines to show in change notes
  • Loading branch information
edwardkerry authored Jan 15, 2020
2 parents f9aeec1 + 4b2a61f commit 7427c4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/components/_published-dates.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/views/components/_published-dates.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<% history.each do |change| %>
<li class="app-c-published-dates__change-item">
<time class="app-c-published-dates__change-date timestamp" datetime="<%= change[:timestamp] %>"><%= change[:display_time] %></time>
<%= change[:note] %>
<p class="app-c-published-dates__change-note"><%= change[:note].strip %></p>
</li>
<% end %>
</ol>
Expand Down
10 changes: 10 additions & 0 deletions test/components/published_dates_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7427c4a

Please sign in to comment.