govspeak 6.4.0 → 6.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -2
- data/README.md +6 -5
- data/Rakefile +1 -1
- data/lib/govspeak.rb +76 -76
- data/lib/govspeak/header_extractor.rb +1 -1
- data/lib/govspeak/html_sanitizer.rb +10 -15
- data/lib/govspeak/link_extractor.rb +3 -3
- data/lib/govspeak/post_processor.rb +30 -12
- data/lib/govspeak/presenters/attachment_presenter.rb +32 -32
- data/lib/govspeak/presenters/contact_presenter.rb +2 -2
- data/lib/govspeak/presenters/h_card_presenter.rb +3 -3
- data/lib/govspeak/presenters/image_presenter.rb +2 -2
- data/lib/govspeak/version.rb +1 -1
- data/lib/kramdown/parser/govuk.rb +3 -3
- data/test/blockquote_extra_quote_remover_test.rb +10 -10
- data/test/govspeak_attachments_image_test.rb +10 -10
- data/test/govspeak_attachments_inline_test.rb +18 -18
- data/test/govspeak_button_test.rb +21 -21
- data/test/govspeak_contacts_test.rb +18 -18
- data/test/govspeak_extract_contact_content_ids_test.rb +1 -1
- data/test/govspeak_images_bang_test.rb +14 -14
- data/test/govspeak_images_test.rb +16 -16
- data/test/govspeak_link_test.rb +1 -1
- data/test/govspeak_structured_headers_test.rb +2 -2
- data/test/govspeak_table_with_headers_test.rb +1 -1
- data/test/govspeak_test.rb +18 -18
- data/test/html_sanitizer_test.rb +25 -7
- data/test/html_validator_test.rb +2 -2
- data/test/presenters/h_card_presenter_test.rb +39 -39
- data/test/test_helper.rb +6 -6
- metadata +51 -39
@@ -1,55 +1,55 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "test_helper"
|
4
|
+
require "govspeak_test_helper"
|
5
5
|
|
6
|
-
require
|
6
|
+
require "ostruct"
|
7
7
|
|
8
8
|
class GovspeakTest < Minitest::Test
|
9
9
|
include GovspeakTestHelper
|
10
10
|
|
11
11
|
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
|
12
|
+
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
13
|
assert_text_output "Start now"
|
14
14
|
end
|
15
15
|
|
16
16
|
# The same as above but with line breaks
|
17
17
|
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
|
18
|
+
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
19
|
assert_text_output "Start now"
|
20
20
|
end
|
21
21
|
|
22
22
|
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
|
23
|
+
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
24
|
assert_text_output "Start now"
|
25
25
|
end
|
26
26
|
|
27
27
|
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
|
28
|
+
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
29
|
assert_text_output "Start now"
|
30
30
|
end
|
31
31
|
|
32
32
|
test_given_govspeak "{button}[Start now](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
33
|
-
assert_html_output '<p><a
|
33
|
+
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
34
|
assert_text_output "Start now"
|
35
35
|
end
|
36
36
|
|
37
37
|
# Test other text outputs
|
38
38
|
test_given_govspeak "{button}[Something else](https://www.registertovote.service.gov.uk/register-to-vote/start){/button}" do
|
39
|
-
assert_html_output '<p><a
|
39
|
+
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
40
|
assert_text_output "Something else"
|
41
41
|
end
|
42
42
|
|
43
43
|
# Test that nothing renders when not given a link
|
44
44
|
test_given_govspeak "{button}I shouldn't render a button{/button}" do
|
45
|
-
assert_html_output
|
45
|
+
assert_html_output "<p>{button}I shouldn’t render a button{/button}</p>"
|
46
46
|
end
|
47
47
|
|
48
48
|
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
49
|
assert_html_output %{
|
50
50
|
<p>Text before the button with line breaks</p>
|
51
51
|
|
52
|
-
<p><a
|
52
|
+
<p><a class="gem-c-button govuk-button" role="button" href="http://www.gov.uk">Start Now</a></p>
|
53
53
|
|
54
54
|
<p>test after the button</p>
|
55
55
|
}
|
@@ -58,17 +58,17 @@ class GovspeakTest < Minitest::Test
|
|
58
58
|
|
59
59
|
# Test README examples
|
60
60
|
test_given_govspeak "{button}[Continue](https://gov.uk/random){/button}" do
|
61
|
-
assert_html_output '<p><a
|
61
|
+
assert_html_output '<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>'
|
62
62
|
assert_text_output "Continue"
|
63
63
|
end
|
64
64
|
|
65
65
|
test_given_govspeak "{button start}[Start Now](https://gov.uk/random){/button}" do
|
66
|
-
assert_html_output '<p><a
|
66
|
+
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
67
|
assert_text_output "Start Now"
|
68
68
|
end
|
69
69
|
|
70
70
|
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
|
71
|
+
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
72
|
assert_text_output "Start Now"
|
73
73
|
end
|
74
74
|
|
@@ -83,21 +83,21 @@ class GovspeakTest < Minitest::Test
|
|
83
83
|
# Make sure button renders when typical linebreaks are before it, seen in publishing applications
|
84
84
|
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
85
|
assert_html_output %{
|
86
|
-
<p><a
|
86
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Line breaks</a></p>
|
87
87
|
|
88
|
-
<p><a
|
88
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
89
89
|
|
90
|
-
<p><a
|
90
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
91
91
|
}
|
92
92
|
end
|
93
93
|
|
94
94
|
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
95
|
assert_html_output %{
|
96
|
-
<p><a
|
96
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">More line breaks</a></p>
|
97
97
|
|
98
|
-
<p><a
|
98
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
99
99
|
|
100
|
-
<p><a
|
100
|
+
<p><a class="gem-c-button govuk-button" role="button" href="https://gov.uk/random">Continue</a></p>
|
101
101
|
}
|
102
102
|
end
|
103
103
|
|
@@ -122,7 +122,7 @@ class GovspeakTest < Minitest::Test
|
|
122
122
|
<p>lorem lorem lorem
|
123
123
|
lorem lorem lorem</p>
|
124
124
|
|
125
|
-
<p><a
|
125
|
+
<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
126
|
|
127
127
|
<p>lorem lorem lorem
|
128
128
|
lorem lorem lorem</p>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
class GovspeakContactsTest < Minitest::Test
|
6
6
|
def build_contact(attrs = {})
|
@@ -19,8 +19,8 @@ class GovspeakContactsTest < Minitest::Test
|
|
19
19
|
region: "London",
|
20
20
|
postal_code: "WC2B 6NH",
|
21
21
|
world_location: "United Kingdom",
|
22
|
-
}
|
23
|
-
]
|
22
|
+
},
|
23
|
+
],
|
24
24
|
),
|
25
25
|
email_addresses: attrs.fetch(
|
26
26
|
:email_addresses,
|
@@ -28,8 +28,8 @@ class GovspeakContactsTest < Minitest::Test
|
|
28
28
|
{
|
29
29
|
title: "",
|
30
30
|
email: "people@digital.cabinet-office.gov.uk",
|
31
|
-
}
|
32
|
-
]
|
31
|
+
},
|
32
|
+
],
|
33
33
|
),
|
34
34
|
phone_numbers: attrs.fetch(
|
35
35
|
:phone_numbers,
|
@@ -37,23 +37,23 @@ class GovspeakContactsTest < Minitest::Test
|
|
37
37
|
{
|
38
38
|
title: "helpdesk",
|
39
39
|
number: "+4412345 67890",
|
40
|
-
}
|
41
|
-
]
|
40
|
+
},
|
41
|
+
],
|
42
42
|
),
|
43
43
|
contact_form_links: attrs.fetch(
|
44
44
|
:contact_form_links,
|
45
45
|
[
|
46
46
|
{
|
47
|
-
link: "https://www.gov.uk/contact"
|
48
|
-
}
|
49
|
-
]
|
50
|
-
)
|
51
|
-
}
|
47
|
+
link: "https://www.gov.uk/contact",
|
48
|
+
},
|
49
|
+
],
|
50
|
+
),
|
51
|
+
},
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
55
55
|
def compress_html(html)
|
56
|
-
html.gsub(/[\n\r]+[\s]*/,
|
56
|
+
html.gsub(/[\n\r]+[\s]*/, "")
|
57
57
|
end
|
58
58
|
|
59
59
|
test "contact is rendered when present in options[:contacts]" do
|
@@ -136,7 +136,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
136
136
|
{
|
137
137
|
street_address: "125 Kingsway",
|
138
138
|
country_name: "United Kingdom",
|
139
|
-
}
|
139
|
+
},
|
140
140
|
])
|
141
141
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
142
142
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
@@ -152,7 +152,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
152
152
|
contact = build_contact(post_addresses: [
|
153
153
|
{
|
154
154
|
street_address: "",
|
155
|
-
}
|
155
|
+
},
|
156
156
|
])
|
157
157
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
158
158
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
@@ -163,7 +163,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
163
163
|
contact = build_contact(email_addresses: [
|
164
164
|
{
|
165
165
|
email: "",
|
166
|
-
}
|
166
|
+
},
|
167
167
|
])
|
168
168
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
169
169
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
@@ -174,7 +174,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
174
174
|
contact = build_contact(contact_form_links: [
|
175
175
|
{
|
176
176
|
link: "",
|
177
|
-
}
|
177
|
+
},
|
178
178
|
])
|
179
179
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
180
180
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
@@ -185,7 +185,7 @@ class GovspeakContactsTest < Minitest::Test
|
|
185
185
|
contact = build_contact(phone_numbers: [
|
186
186
|
{
|
187
187
|
number: "",
|
188
|
-
}
|
188
|
+
},
|
189
189
|
])
|
190
190
|
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
|
191
191
|
rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "test_helper"
|
4
|
+
require "govspeak_test_helper"
|
5
5
|
|
6
6
|
class GovspeakImagesBangTest < Minitest::Test
|
7
7
|
include GovspeakTestHelper
|
@@ -22,7 +22,7 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
22
22
|
assert_html_output(
|
23
23
|
%{<figure class="image embedded">} +
|
24
24
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
25
|
-
%{</figure>}
|
25
|
+
%{</figure>},
|
26
26
|
)
|
27
27
|
end
|
28
28
|
end
|
@@ -32,7 +32,7 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
32
32
|
assert_html_output(
|
33
33
|
%{<figure class="image embedded">} +
|
34
34
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&"<>"></div>} +
|
35
|
-
%{</figure>}
|
35
|
+
%{</figure>},
|
36
36
|
)
|
37
37
|
end
|
38
38
|
end
|
@@ -48,49 +48,49 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
48
48
|
end
|
49
49
|
|
50
50
|
test "!!n syntax adds image caption if given" do
|
51
|
-
given_govspeak "!!1", images: [Image.new(caption:
|
51
|
+
given_govspeak "!!1", images: [Image.new(caption: "My Caption & so on")] do
|
52
52
|
assert_html_output(
|
53
53
|
%{<figure class="image embedded">} +
|
54
54
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
|
55
55
|
%{<figcaption><p>My Caption & so on</p></figcaption>} +
|
56
|
-
%{</figure>}
|
56
|
+
%{</figure>},
|
57
57
|
)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
test "!!n syntax ignores a blank caption" do
|
62
|
-
given_govspeak "!!1", images: [Image.new(caption:
|
62
|
+
given_govspeak "!!1", images: [Image.new(caption: " ")] do
|
63
63
|
assert_html_output(
|
64
64
|
%{<figure class="image embedded">} +
|
65
65
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
66
|
-
%{</figure>}
|
66
|
+
%{</figure>},
|
67
67
|
)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
test "¡¡n syntax adds image credit if given" do
|
72
|
-
given_govspeak "!!1", images: [Image.new(credit:
|
72
|
+
given_govspeak "!!1", images: [Image.new(credit: "My Credit & so on")] do
|
73
73
|
assert_html_output(
|
74
74
|
%{<figure class="image embedded">} +
|
75
75
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
|
76
76
|
%{<figcaption><p>Image credit: My Credit & so on</p></figcaption>} +
|
77
|
-
%{</figure>}
|
77
|
+
%{</figure>},
|
78
78
|
)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
test "!!n syntax ignores a blank credit" do
|
83
|
-
given_govspeak "!!1", images: [Image.new(credit:
|
83
|
+
given_govspeak "!!1", images: [Image.new(credit: " ")] do
|
84
84
|
assert_html_output(
|
85
85
|
%{<figure class="image embedded">} +
|
86
86
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
87
|
-
%{</figure>}
|
87
|
+
%{</figure>},
|
88
88
|
)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
test "!!n syntax adds image caption and credit if given" do
|
93
|
-
given_govspeak "!!1", images: [Image.new(caption:
|
93
|
+
given_govspeak "!!1", images: [Image.new(caption: "My Caption & so on", credit: "My Credit & so on")] do
|
94
94
|
assert_html_output(
|
95
95
|
%{<figure class="image embedded">} +
|
96
96
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
|
@@ -98,7 +98,7 @@ class GovspeakImagesBangTest < Minitest::Test
|
|
98
98
|
%{<p>My Caption & so on</p>\n} +
|
99
99
|
%{<p>Image credit: My Credit & so on</p>} +
|
100
100
|
%{</figcaption>} +
|
101
|
-
%{</figure>}
|
101
|
+
%{</figure>},
|
102
102
|
)
|
103
103
|
end
|
104
104
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "test_helper"
|
4
|
+
require "govspeak_test_helper"
|
5
5
|
|
6
6
|
class GovspeakImagesTest < Minitest::Test
|
7
7
|
include GovspeakTestHelper
|
@@ -18,7 +18,7 @@ class GovspeakImagesTest < Minitest::Test
|
|
18
18
|
assert_html_output(
|
19
19
|
%{<figure class="image embedded">} +
|
20
20
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
21
|
-
%{</figure>}
|
21
|
+
%{</figure>},
|
22
22
|
)
|
23
23
|
end
|
24
24
|
end
|
@@ -28,7 +28,7 @@ class GovspeakImagesTest < Minitest::Test
|
|
28
28
|
assert_html_output(
|
29
29
|
%{<figure class="image embedded">} +
|
30
30
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt '&"<>"></div>} +
|
31
|
-
%{</figure>}
|
31
|
+
%{</figure>},
|
32
32
|
)
|
33
33
|
end
|
34
34
|
end
|
@@ -39,49 +39,49 @@ class GovspeakImagesTest < Minitest::Test
|
|
39
39
|
end
|
40
40
|
|
41
41
|
test "Image:image-id syntax adds image caption if given" do
|
42
|
-
given_govspeak "[Image:image-id]", images: [build_image(caption:
|
42
|
+
given_govspeak "[Image:image-id]", images: [build_image(caption: "My Caption & so on")] do
|
43
43
|
assert_html_output(
|
44
44
|
%{<figure class="image embedded">} +
|
45
45
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
|
46
46
|
%{<figcaption><p>My Caption & so on</p></figcaption>} +
|
47
|
-
%{</figure>}
|
47
|
+
%{</figure>},
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
test "Image:image-id syntax ignores a blank caption" do
|
53
|
-
given_govspeak "[Image:image-id]", images: [build_image(caption:
|
53
|
+
given_govspeak "[Image:image-id]", images: [build_image(caption: " ")] do
|
54
54
|
assert_html_output(
|
55
55
|
%{<figure class="image embedded">} +
|
56
56
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
57
|
-
%{</figure>}
|
57
|
+
%{</figure>},
|
58
58
|
)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
test "Image:image-id syntax adds image credit if given" do
|
63
|
-
given_govspeak "[Image:image-id]", images: [build_image(credit:
|
63
|
+
given_govspeak "[Image:image-id]", images: [build_image(credit: "My Credit & so on")] do
|
64
64
|
assert_html_output(
|
65
65
|
%{<figure class="image embedded">} +
|
66
66
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
|
67
67
|
%{<figcaption><p>Image credit: My Credit & so on</p></figcaption>} +
|
68
|
-
%{</figure>}
|
68
|
+
%{</figure>},
|
69
69
|
)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
test "Image:image-id syntax ignores a blank credit" do
|
74
|
-
given_govspeak "[Image:image-id]", images: [build_image(credit:
|
74
|
+
given_govspeak "[Image:image-id]", images: [build_image(credit: " ")] do
|
75
75
|
assert_html_output(
|
76
76
|
%{<figure class="image embedded">} +
|
77
77
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
78
|
-
%{</figure>}
|
78
|
+
%{</figure>},
|
79
79
|
)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
test "Image:image-id syntax adds image caption and credit if given" do
|
84
|
-
given_govspeak "[Image:image-id]", images: [build_image(caption:
|
84
|
+
given_govspeak "[Image:image-id]", images: [build_image(caption: "My Caption & so on", credit: "My Credit & so on")] do
|
85
85
|
assert_html_output(
|
86
86
|
%{<figure class="image embedded">} +
|
87
87
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>\n} +
|
@@ -89,7 +89,7 @@ class GovspeakImagesTest < Minitest::Test
|
|
89
89
|
%{<p>My Caption & so on</p>\n} +
|
90
90
|
%{<p>Image credit: My Credit & so on</p>} +
|
91
91
|
%{</figcaption>} +
|
92
|
-
%{</figure>}
|
92
|
+
%{</figure>},
|
93
93
|
)
|
94
94
|
end
|
95
95
|
end
|
@@ -103,7 +103,7 @@ class GovspeakImagesTest < Minitest::Test
|
|
103
103
|
assert_html_output(
|
104
104
|
%{<figure class="image embedded">} +
|
105
105
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
106
|
-
%{</figure>}
|
106
|
+
%{</figure>},
|
107
107
|
)
|
108
108
|
end
|
109
109
|
|
@@ -112,7 +112,7 @@ class GovspeakImagesTest < Minitest::Test
|
|
112
112
|
%{<figure class="image embedded">} +
|
113
113
|
%{<div class="img"><img src="http://example.com/image.jpg" alt="my alt"></div>} +
|
114
114
|
%{</figure>\n} +
|
115
|
-
%{<p>some text</p>}
|
115
|
+
%{<p>some text</p>},
|
116
116
|
)
|
117
117
|
end
|
118
118
|
end
|