Skip to content

Commit

Permalink
Merge pull request #3220 from alphagov/fix-components-test
Browse files Browse the repository at this point in the history
Fix components test
  • Loading branch information
andysellick authored Jun 12, 2024
2 parents 33ec5e7 + b6ca36b commit 5b81c7e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
12 changes: 9 additions & 3 deletions app/views/components/_contents_list_with_body.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
<% unless block.empty? %>
<%
contents ||= []
sticky_attr = ' data-module="sticky-element-container"'.html_safe if contents.any?
sticky_attr = "sticky-element-container" if contents.any?
%>
<div id="contents" class="app-c-contents-list-with-body"<%= sticky_attr %>>
<%= tag.div(
id: "contents",
class: "app-c-contents-list-with-body",
data: {
module: sticky_attr,
},
) do %>
<% if contents.any? %>
<div class="responsive-bottom-margin">
<%= render 'govuk_publishing_components/components/contents_list', contents: contents %>
Expand All @@ -19,5 +25,5 @@
</div>
</div>
<% end %>
</div>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/components/_important_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title = local_assigns[:title]
items = local_assigns[:items] || {}
items = items.reject { |k,v| v.nil? }
items = items.merge(items) { |k,v| Array(v).join(", ").html_safe }
items = items.merge(items) { |k,v| Array(v).join(", ") }
margin_bottom_class = " app-c-important-metadata--bottom-margin" unless local_assigns[:margin_bottom]
-%>
<% if items.any? %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/components/docs/contents_list_with_body.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ examples:
<h3 id="contact">Contact</h3>
<p>Please send written representations about any competition issues to:</p>
<div class="address"><div class="adr org fn"><p>
<br>Competition and Markets Authority
<br>Victoria House
<br>Southampton Row
<br>London
<br>Competition and Markets Authority
<br>Victoria House
<br>Southampton Row
<br>London
<br>WC1B 4AD
<br>
</p></div></div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/components/docs/important_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ examples:
data:
items:
Many things:
- First thing
- Second thing
- Third thing
- <a href="#">First thing</a>
- <a href="#">Second thing</a>
- <a href="#">Third thing</a>
with_title:
description: Used on statistics announcements to display release date changed information, [see example](https://gov.uk/government/statistics/announcements/museums-and-galleries-monthly-visits--8)
data:
Expand Down
4 changes: 2 additions & 2 deletions test/components/all_components_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class AllComponentsTest < ActionController::TestCase
assert File.exist?(css_file)
end

should "not use `html_safe`", not_applicable: component_name.in?(%w[govspeak]) do
should "not use `html_safe`" do
file = File.read(filename)

assert_no_match file, "html_safe"
assert_no_match "html_safe", file
end
end
end
Expand Down

0 comments on commit 5b81c7e

Please sign in to comment.