Skip to content

Commit

Permalink
Remove trailing and leading whitespace from change notes
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardkerry committed Jan 15, 2020
1 parent be3274a commit 4b2a61f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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>
<p class="app-c-published-dates__change-note"><%= change[:note] %></p>
<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 4b2a61f

Please sign in to comment.