govspeak 6.5.2 → 6.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +6 -5
- data/Rakefile +6 -3
- data/lib/govspeak.rb +56 -54
- data/lib/govspeak/html_sanitizer.rb +6 -4
- data/lib/govspeak/kramdown_overrides.rb +2 -2
- data/lib/govspeak/link_extractor.rb +3 -3
- data/lib/govspeak/post_processor.rb +25 -5
- data/lib/govspeak/presenters/attachment_presenter.rb +26 -26
- data/lib/govspeak/presenters/image_presenter.rb +2 -2
- data/lib/govspeak/structured_header_extractor.rb +2 -2
- data/lib/govspeak/version.rb +1 -1
- data/lib/kramdown/parser/govuk.rb +4 -5
- data/test/blockquote_extra_quote_remover_test.rb +25 -27
- data/test/govspeak_attachment_link_test.rb +0 -2
- data/test/govspeak_attachment_test.rb +0 -2
- data/test/govspeak_attachments_image_test.rb +2 -4
- data/test/govspeak_attachments_inline_test.rb +4 -6
- data/test/govspeak_button_test.rb +25 -27
- data/test/govspeak_contacts_test.rb +11 -13
- data/test/govspeak_extract_contact_content_ids_test.rb +0 -2
- data/test/govspeak_images_bang_test.rb +30 -32
- data/test/govspeak_images_test.rb +36 -38
- data/test/govspeak_link_extractor_test.rb +1 -1
- data/test/govspeak_link_test.rb +0 -2
- data/test/govspeak_structured_headers_test.rb +5 -4
- data/test/govspeak_table_with_headers_test.rb +67 -20
- data/test/govspeak_test.rb +80 -83
- data/test/govspeak_test_helper.rb +1 -1
- data/test/html_sanitizer_test.rb +0 -1
- data/test/presenters/h_card_presenter_test.rb +0 -2
- data/test/test_helper.rb +6 -2
- metadata +40 -34
@@ -33,8 +33,8 @@ module Govspeak
|
|
33
33
|
def figcaption_html
|
34
34
|
lines = []
|
35
35
|
lines << "<figcaption>"
|
36
|
-
lines << %
|
37
|
-
lines << %
|
36
|
+
lines << %(<p>#{caption}</p>) if caption.present?
|
37
|
+
lines << %(<p>#{I18n.t('govspeak.image.figure.credit', credit: credit)}</p>) if credit.present?
|
38
38
|
lines << "</figcaption>"
|
39
39
|
lines.join
|
40
40
|
end
|
@@ -48,9 +48,9 @@ module Govspeak
|
|
48
48
|
private :doc, :stack, :structured_headers
|
49
49
|
|
50
50
|
def headers_list
|
51
|
-
@headers_list ||= doc.headers.map
|
51
|
+
@headers_list ||= doc.headers.map do |h|
|
52
52
|
StructuredHeader.new(h.text, h.level, h.id, [])
|
53
|
-
|
53
|
+
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def add_top_level(header)
|
data/lib/govspeak/version.rb
CHANGED
@@ -9,7 +9,7 @@ module Kramdown
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
define(:document_domains, Object, %w
|
12
|
+
define(:document_domains, Object, %w[www.gov.uk], <<~DESCRIPTION) do |val|
|
13
13
|
Defines the domains which are considered local to the document
|
14
14
|
|
15
15
|
Default: www.gov.uk
|
@@ -21,10 +21,10 @@ module Kramdown
|
|
21
21
|
|
22
22
|
module Parser
|
23
23
|
class Govuk < Kramdown::Parser::Kramdown
|
24
|
-
CUSTOM_INLINE_ELEMENTS = %w
|
24
|
+
CUSTOM_INLINE_ELEMENTS = %w[govspeak-embed-attachment-link].freeze
|
25
25
|
|
26
26
|
def initialize(source, options)
|
27
|
-
@document_domains = options[:document_domains] || %w
|
27
|
+
@document_domains = options[:document_domains] || %w[www.gov.uk]
|
28
28
|
super
|
29
29
|
end
|
30
30
|
|
@@ -35,11 +35,10 @@ module Kramdown
|
|
35
35
|
unless host.nil? || @document_domains.compact.include?(host)
|
36
36
|
element.attr["rel"] = "external"
|
37
37
|
end
|
38
|
-
# rubocop:disable Lint/SuppressedException
|
39
38
|
rescue Addressable::URI::InvalidURIError
|
40
39
|
# it's safe to ignore these very *specific* exceptions
|
41
40
|
end
|
42
|
-
|
41
|
+
|
43
42
|
end
|
44
43
|
super
|
45
44
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class BlockquoteExtraQuoteRemoverTest < Minitest::Test
|
@@ -14,85 +12,85 @@ class BlockquoteExtraQuoteRemoverTest < Minitest::Test
|
|
14
12
|
end
|
15
13
|
|
16
14
|
test "ignores nil" do
|
17
|
-
|
15
|
+
assert_nil Govspeak::BlockquoteExtraQuoteRemover.remove(nil)
|
18
16
|
end
|
19
17
|
|
20
18
|
test "ignores text without double quotes" do
|
21
|
-
assert_leaves_untouched %
|
19
|
+
assert_leaves_untouched %(no quotes\na few lines,\n\n\n\nbut no quotes\n\n)
|
22
20
|
end
|
23
21
|
|
24
22
|
test "ignores text without a quote symbol" do
|
25
|
-
assert_leaves_untouched %
|
23
|
+
assert_leaves_untouched %(quotes\n"but not with a > symbol")
|
26
24
|
end
|
27
25
|
|
28
26
|
test "transforms text with surrounding quotes" do
|
29
27
|
assert_remover_transforms(
|
30
|
-
%
|
31
|
-
%
|
28
|
+
%(He said:\n> "yes, it's true!"\n\napparently.) =>
|
29
|
+
%(He said:\n> yes, it's true!\n\napparently.),
|
32
30
|
)
|
33
31
|
end
|
34
32
|
|
35
33
|
test "leaves quotes in the middle of the string" do
|
36
34
|
assert_remover_transforms(
|
37
|
-
%
|
38
|
-
%
|
35
|
+
%(He said:\n> "yes, it's true!" whilst sipping a cocktail. "And yes, I did rather enjoy it." \n\napparently.) =>
|
36
|
+
%(He said:\n> yes, it's true!" whilst sipping a cocktail. "And yes, I did rather enjoy it.\n\napparently.),
|
39
37
|
)
|
40
38
|
end
|
41
39
|
|
42
40
|
test "leaves trailing text and quote intact" do
|
43
41
|
assert_remover_transforms(
|
44
|
-
%
|
45
|
-
%
|
42
|
+
%(He said:\n> "yes, it's true!" whilst sipping a cocktail.) =>
|
43
|
+
%(He said:\n> yes, it's true!" whilst sipping a cocktail.),
|
46
44
|
)
|
47
45
|
end
|
48
46
|
|
49
47
|
test "windows line breaks" do
|
50
48
|
assert_remover_transforms(
|
51
|
-
%
|
52
|
-
%
|
49
|
+
%(Sir George Young MP, said\r\n> "I welcome the positive public response to the e-petitions site, which is important way of building a bridge between people and Parliament.”\r\n## The special relationship) =>
|
50
|
+
%(Sir George Young MP, said\r\n> I welcome the positive public response to the e-petitions site, which is important way of building a bridge between people and Parliament.\r\n## The special relationship),
|
53
51
|
)
|
54
52
|
end
|
55
53
|
|
56
54
|
test "no space in front" do
|
57
55
|
assert_remover_transforms(
|
58
|
-
%
|
59
|
-
%
|
56
|
+
%(>"As we continue with the redundancy process we will ensure we retain the capabilities that our armed forces will require to meet the challenges of the future. The redundancy programme will not impact adversely on the current operations in Afghanistan, where our armed forces continue to fight so bravely on this country's behalf.") =>
|
57
|
+
%(> As we continue with the redundancy process we will ensure we retain the capabilities that our armed forces will require to meet the challenges of the future. The redundancy programme will not impact adversely on the current operations in Afghanistan, where our armed forces continue to fight so bravely on this country's behalf.),
|
60
58
|
)
|
61
59
|
end
|
62
60
|
|
63
61
|
test "handles space after a quote" do
|
64
62
|
assert_remover_transforms(
|
65
|
-
%
|
66
|
-
%
|
63
|
+
%(>" Test") =>
|
64
|
+
%(> Test),
|
67
65
|
)
|
68
66
|
end
|
69
67
|
|
70
68
|
test "remove double double quotes" do
|
71
69
|
assert_remover_transforms(
|
72
|
-
%
|
73
|
-
%
|
70
|
+
%(We heard it said:\n\n> ""Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners."") =>
|
71
|
+
%(We heard it said:\n\n> Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.),
|
74
72
|
)
|
75
73
|
assert_remover_transforms(
|
76
|
-
%
|
77
|
-
%
|
74
|
+
%(> ""Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.) =>
|
75
|
+
%(> Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.),
|
78
76
|
)
|
79
77
|
end
|
80
78
|
|
81
79
|
test "removes quotes correctly from multi-line blockquotes" do
|
82
80
|
assert_remover_transforms(
|
83
|
-
%
|
84
|
-
%
|
81
|
+
%(> "Here is a block quote using 2 lines and two of the arrows.\n> I am not sure how this will render. I think it will mash them together.") =>
|
82
|
+
%(> Here is a block quote using 2 lines and two of the arrows.\n> I am not sure how this will render. I think it will mash them together.),
|
85
83
|
)
|
86
84
|
end
|
87
85
|
|
88
86
|
test "preserves multiline blockquotes with plain newlines quotes" do
|
89
87
|
assert_remover_transforms(
|
90
|
-
%
|
91
|
-
%
|
92
|
-
|
88
|
+
%(> "line 1\n> \n> "line 2\n> \n> "line 3") =>
|
89
|
+
%(> line 1\n> \n> line 2\n> \n> line 3),
|
90
|
+
)
|
93
91
|
end
|
94
92
|
|
95
93
|
test "preserve newlines when there's a blockquote with additional text after" do
|
96
|
-
assert_leaves_untouched(%
|
94
|
+
assert_leaves_untouched(%(> \n> blah))
|
97
95
|
end
|
98
96
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class GovspeakAttachmentsImageTest < Minitest::Test
|
@@ -77,11 +75,11 @@ class GovspeakAttachmentsImageTest < Minitest::Test
|
|
77
75
|
"[embed:attachments:image:1fe8]",
|
78
76
|
[build_attachment(id: 10, url: "http://a.b/c.jpg", title: "My Title", content_id: "1fe8")],
|
79
77
|
)
|
80
|
-
expected_html_output = %
|
78
|
+
expected_html_output = %(
|
81
79
|
<figure id="attachment_10" class="image embedded">
|
82
80
|
<div class="img"><img src="http://a.b/c.jpg" alt="My Title"></div>
|
83
81
|
</figure>
|
84
|
-
|
82
|
+
)
|
85
83
|
assert_match(compress_html(expected_html_output), compress_html(rendered))
|
86
84
|
end
|
87
85
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class GovspeakAttachmentsInlineTest < Minitest::Test
|
@@ -141,10 +139,10 @@ class GovspeakAttachmentsInlineTest < Minitest::Test
|
|
141
139
|
number_of_pages: 2,
|
142
140
|
)],
|
143
141
|
)
|
144
|
-
link = %
|
145
|
-
type = %
|
146
|
-
file_size = %
|
147
|
-
pages = %
|
142
|
+
link = %(<a href="#{Regexp.quote('http://a.b/test.txt')}">My Attached Text File</a>)
|
143
|
+
type = %(<span class="type">Plain text</span>)
|
144
|
+
file_size = %(<span class="file-size">2 KB</span>)
|
145
|
+
pages = %(<span class="page-length">2 pages</span>)
|
148
146
|
assert_match(/#{link}\s+\(#{type}, #{file_size}, #{pages}\)/, rendered)
|
149
147
|
end
|
150
148
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
require "govspeak_test_helper"
|
5
3
|
|
@@ -9,34 +7,34 @@ class GovspeakTest < Minitest::Test
|
|
9
7
|
include GovspeakTestHelper
|
10
8
|
|
11
9
|
test_given_govspeak "{button start cross-domain-tracking:UA-23066786-5}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
12
|
-
assert_html_output '<p><a
|
10
|
+
assert_html_output '<p><a class="gem-c-button govuk-button govuk-button--start" role="button" data-module="cross-domain-tracking" data-tracking-code="UA-23066786-5" data-tracking-name="govspeakButtonTracker" href="https://www.registertovote.service.gov.uk/register-to-vote/start"> Start now <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>'
|
13
11
|
assert_text_output "Start now"
|
14
12
|
end
|
15
13
|
|
16
14
|
# The same as above but with line breaks
|
17
15
|
test_given_govspeak "{button start cross-domain-tracking:UA-23066786-5}\n\n\n[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start)\n\n\n{/button}" do
|
18
|
-
assert_html_output '<p><a
|
16
|
+
assert_html_output '<p><a class="gem-c-button govuk-button govuk-button--start" role="button" data-module="cross-domain-tracking" data-tracking-code="UA-23066786-5" data-tracking-name="govspeakButtonTracker" href="https://www.registertovote.service.gov.uk/register-to-vote/start"> Start now <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>'
|
19
17
|
assert_text_output "Start now"
|
20
18
|
end
|
21
19
|
|
22
20
|
test_given_govspeak "{button cross-domain-tracking:UA-23066786-5}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
23
|
-
assert_html_output '<p><a
|
21
|
+
assert_html_output '<p><a class="gem-c-button govuk-button" role="button" data-module="cross-domain-tracking" data-tracking-code="UA-23066786-5" data-tracking-name="govspeakButtonTracker" href="https://www.registertovote.service.gov.uk/register-to-vote/start">Start now</a></p>'
|
24
22
|
assert_text_output "Start now"
|
25
23
|
end
|
26
24
|
|
27
25
|
test_given_govspeak "{button start}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
28
|
-
assert_html_output '<p><a
|
26
|
+
assert_html_output '<p><a class="gem-c-button govuk-button govuk-button--start" role="button" href="https://www.registertovote.service.gov.uk/register-to-vote/start"> Start now <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>'
|
29
27
|
assert_text_output "Start now"
|
30
28
|
end
|
31
29
|
|
32
30
|
test_given_govspeak "{button}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
33
|
-
assert_html_output '<p><a
|
31
|
+
assert_html_output '<p><a class="gem-c-button govuk-button" role="button" href="https://www.registertovote.service.gov.uk/register-to-vote/start">Start now</a></p>'
|
34
32
|
assert_text_output "Start now"
|
35
33
|
end
|
36
34
|
|
37
35
|
# Test other text outputs
|
38
36
|
test_given_govspeak "{button}[Something else](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
39
|
-
assert_html_output '<p><a
|
37
|
+
assert_html_output '<p><a class="gem-c-button govuk-button" role="button" href="https://www.registertovote.service.gov.uk/register-to-vote/start">Something else</a></p>'
|
40
38
|
assert_text_output "Something else"
|
41
39
|
end
|
42
40
|
|
@@ -46,29 +44,29 @@ class GovspeakTest < Minitest::Test
|
|
46
44
|
end
|
47
45
|
|
48
46
|
test_given_govspeak "Text before the button with line breaks \n\n\n{button}[Start Now](http://www.gov.uk){/button}\n\n\n test after the button" do
|
49
|
-
assert_html_output %
|
47
|
+
assert_html_output %(
|
50
48
|
<p>Text before the button with line breaks</p>
|
51
49
|
|
52
|
-
<p><a
|
50
|
+
<p><a class="gem-c-button govuk-button" role="button" href="http://www.gov.uk">Start Now</a></p>
|
53
51
|
|
54
52
|
<p>test after the button</p>
|
55
|
-
|
53
|
+
)
|
56
54
|
assert_text_output "Text before the button with line breaks Start Now test after the button"
|
57
55
|
end
|
58
56
|
|
59
57
|
# Test README examples
|
60
58
|
test_given_govspeak "{button}[Continue](https://gov.uk/random){/button}" do
|
61
|
-
assert_html_output '<p><a
|
59
|
+
assert_html_output '<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>'
|
62
60
|
assert_text_output "Continue"
|
63
61
|
end
|
64
62
|
|
65
63
|
test_given_govspeak "{button start}[Start Now](https://gov.uk/random){/button}" do
|
66
|
-
assert_html_output '<p><a
|
64
|
+
assert_html_output '<p><a class="gem-c-button govuk-button govuk-button--start" role="button" href="https://gov.uk/random"> Start Now <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>'
|
67
65
|
assert_text_output "Start Now"
|
68
66
|
end
|
69
67
|
|
70
68
|
test_given_govspeak "{button start cross-domain-tracking:UA-XXXXXX-Y}[Start Now](https://example.com/external-service/start-now){/button}" do
|
71
|
-
assert_html_output '<p><a
|
69
|
+
assert_html_output '<p><a class="gem-c-button govuk-button govuk-button--start" role="button" data-module="cross-domain-tracking" data-tracking-code="UA-XXXXXX-Y" data-tracking-name="govspeakButtonTracker" href="https://example.com/external-service/start-now"> Start Now <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>'
|
72
70
|
assert_text_output "Start Now"
|
73
71
|
end
|
74
72
|
|
@@ -82,23 +80,23 @@ class GovspeakTest < Minitest::Test
|
|
82
80
|
|
83
81
|
# Make sure button renders when typical linebreaks are before it, seen in publishing applications
|
84
82
|
test_given_govspeak "{button}[Line breaks](https://gov.uk/random){/button}\r\n\r\n{button}[Continue](https://gov.uk/random){/button}\r\n\r\n{button}[Continue](https://gov.uk/random){/button}" do
|
85
|
-
assert_html_output %
|
86
|
-
<p><a
|
83
|
+
assert_html_output %(
|
84
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Line breaks</a></p>
|
87
85
|
|
88
|
-
<p><a
|
86
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
89
87
|
|
90
|
-
<p><a
|
91
|
-
|
88
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
89
|
+
)
|
92
90
|
end
|
93
91
|
|
94
92
|
test_given_govspeak "{button}[More line breaks](https://gov.uk/random){/button}\n\n{button}[Continue](https://gov.uk/random){/button}\n\n{button}[Continue](https://gov.uk/random){/button}" do
|
95
|
-
assert_html_output %
|
96
|
-
<p><a
|
93
|
+
assert_html_output %(
|
94
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">More line breaks</a></p>
|
97
95
|
|
98
|
-
<p><a
|
96
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
99
97
|
|
100
|
-
<p><a
|
101
|
-
|
98
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
99
|
+
)
|
102
100
|
end
|
103
101
|
|
104
102
|
test_given_govspeak %{
|
@@ -114,7 +112,7 @@ class GovspeakTest < Minitest::Test
|
|
114
112
|
lorem lorem lorem
|
115
113
|
lorem lorem lorem
|
116
114
|
} do
|
117
|
-
assert_html_output %
|
115
|
+
assert_html_output %(
|
118
116
|
<h2 id="register-to-vote">Register to vote</h2>
|
119
117
|
|
120
118
|
<p>Introduction text about the service.</p>
|
@@ -122,10 +120,10 @@ class GovspeakTest < Minitest::Test
|
|
122
120
|
<p>lorem lorem lorem
|
123
121
|
lorem lorem lorem</p>
|
124
122
|
|
125
|
-
<p><a
|
123
|
+
<p><a class="gem-c-button govuk-button govuk-button--start" role="button" href="https://gov.uk/random"> Start Now <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewbox="0 0 33 40" role="presentation" focusable="false"><path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path></svg></a></p>
|
126
124
|
|
127
125
|
<p>lorem lorem lorem
|
128
126
|
lorem lorem lorem</p>
|
129
|
-
|
127
|
+
)
|
130
128
|
end
|
131
129
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "test_helper"
|
4
2
|
|
5
3
|
class GovspeakContactsTest < Minitest::Test
|
@@ -61,7 +59,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
61
59
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
62
60
|
|
63
61
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
64
|
-
expected_html_output = %
|
62
|
+
expected_html_output = %(
|
65
63
|
<div id="contact_4f3383e4-48a2-4461-a41d-f85ea8b89ba0" class="contact postal-address">
|
66
64
|
<div class="content">
|
67
65
|
<h3>Government Digital Service</h3>
|
@@ -89,7 +87,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
89
87
|
</div>
|
90
88
|
</div>
|
91
89
|
</div>
|
92
|
-
|
90
|
+
)
|
93
91
|
|
94
92
|
assert_equal(compress_html(expected_html_output), compress_html(rendered))
|
95
93
|
end
|
@@ -105,7 +103,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
105
103
|
contact = build_contact(post_addresses: [])
|
106
104
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
107
105
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
108
|
-
expected_html_output = %
|
106
|
+
expected_html_output = %(
|
109
107
|
<div id="contact_4f3383e4-48a2-4461-a41d-f85ea8b89ba0" class="contact">
|
110
108
|
<div class="content">
|
111
109
|
<h3>Government Digital Service</h3>
|
@@ -127,7 +125,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
127
125
|
</div>
|
128
126
|
</div>
|
129
127
|
</div>
|
130
|
-
|
128
|
+
)
|
131
129
|
assert_equal(compress_html(expected_html_output), compress_html(rendered))
|
132
130
|
end
|
133
131
|
|
@@ -140,11 +138,11 @@ class GovspeakContactsTest < Minitest::Test
|
|
140
138
|
])
|
141
139
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
142
140
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
143
|
-
expected = %
|
141
|
+
expected = %(
|
144
142
|
<p class="adr">
|
145
143
|
<span class="street-address">125 Kingsway</span>
|
146
144
|
</p>
|
147
|
-
|
145
|
+
)
|
148
146
|
assert_match(compress_html(expected), compress_html(rendered))
|
149
147
|
end
|
150
148
|
|
@@ -156,7 +154,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
156
154
|
])
|
157
155
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
158
156
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
159
|
-
refute_match(%
|
157
|
+
refute_match(%(<p class="adr">), compress_html(rendered))
|
160
158
|
end
|
161
159
|
|
162
160
|
test "contact with an empty email address is not rendered" do
|
@@ -167,7 +165,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
167
165
|
])
|
168
166
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
169
167
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
170
|
-
refute_match(%
|
168
|
+
refute_match(%(<p class="email">), compress_html(rendered))
|
171
169
|
end
|
172
170
|
|
173
171
|
test "contact with an empty contact form is not rendered" do
|
@@ -178,7 +176,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
178
176
|
])
|
179
177
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
180
178
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
181
|
-
refute_match(%
|
179
|
+
refute_match(%(<p class="contact_form_url">), compress_html(rendered))
|
182
180
|
end
|
183
181
|
|
184
182
|
test "contact with an empty phone number is not rendered" do
|
@@ -189,7 +187,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
189
187
|
])
|
190
188
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
191
189
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
192
|
-
refute_match(%
|
190
|
+
refute_match(%(<p class="tel">), compress_html(rendered))
|
193
191
|
end
|
194
192
|
|
195
193
|
test "it auto links text in the description" do
|
@@ -197,7 +195,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
197
195
|
|
198
196
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
199
197
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
200
|
-
assert_match(%
|
198
|
+
assert_match(%(<p class="comments">My description about <a href="https://www.gov.uk">https://www.gov.uk</a></p>),
|
201
199
|
compress_html(rendered))
|
202
200
|
end
|
203
201
|
end
|