summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2018-09-12 17:47:21 -0500
committerBrett Walker <bwalker@gitlab.com>2018-09-13 10:33:06 -0500
commit635d901288d60f73c56859c131e360ddf82d8e34 (patch)
tree58e56bfc9a7eb0aa11ac492d8481b5162714d228 /spec/helpers
parentc7d1eef671dbf598814a6c2ff1f81b924583ae8a (diff)
downloadgitlab-ce-635d901288d60f73c56859c131e360ddf82d8e34.tar.gz
Remove images in 'first_line_in_markdown'
By default, we now strip images in the 'first_line_in_markdown' method. This keeps images from being displayed in the one-liner of both todo and project activity panels. Although not currently used, we allow images to be preserved with the allow_images: true options.
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/markup_helper_spec.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index 9a29ac26eff..a0c0af94fa5 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -339,11 +339,25 @@ describe MarkupHelper do
expect(first_line_in_markdown(object, attribute, 150, project: project)).to eq(expected)
end
- it 'preserves data-src for lazy images' do
- object = create_object("![ImageTest](/uploads/test.png)")
- image_url = "data-src=\".*/uploads/test.png\""
+ context 'when images are allowed' do
+ it 'preserves data-src for lazy images' do
+ object = create_object("![ImageTest](/uploads/test.png)")
+ image_url = "data-src=\".*/uploads/test.png\""
+ text = first_line_in_markdown(object, attribute, 150, project: project, allow_images: true)
+
+ expect(text).to match(image_url)
+ expect(text).to match('<a')
+ end
+ end
- expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(image_url)
+ context 'when images are not allowed' do
+ it 'removes any images' do
+ object = create_object("![ImageTest](/uploads/test.png)")
+ text = first_line_in_markdown(object, attribute, 150, project: project)
+
+ expect(text).not_to match('<img')
+ expect(text).not_to match('<a')
+ end
end
context 'labels formatting' do