diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 17:36:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 17:36:54 +0300 |
commit | f61bb2a16a514b71bf33aabbbb999d6732016a24 (patch) | |
tree | 9548caa89e60b4f40b99bbd1dac030420b812aa8 /spec/lib/banzai/pipeline/wiki_pipeline_spec.rb | |
parent | 35fc54e5d261f8898e390aea7c2f5ec5fdf0539d (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc42
Diffstat (limited to 'spec/lib/banzai/pipeline/wiki_pipeline_spec.rb')
-rw-r--r-- | spec/lib/banzai/pipeline/wiki_pipeline_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb index b102de24041..007d310247b 100644 --- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -289,4 +289,29 @@ RSpec.describe Banzai::Pipeline::WikiPipeline do expect(output).to include('<audio src="/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/audio%20file%20name.wav"') end end + + describe 'gollum tag filters' do + context 'when local image file exists' do + it 'sets the proper attributes for the image' do + gollum_file_double = double('Gollum::File', + mime_type: 'image/jpeg', + name: 'images/image.jpg', + path: 'images/image.jpg', + data: '') + + wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double) + markdown = "[[#{wiki_file.path}]]" + + expect(wiki).to receive(:find_file).with(wiki_file.path, load_content: false).and_return(wiki_file) + + output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) + doc = Nokogiri::HTML::DocumentFragment.parse(output) + + full_path = "/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/#{wiki_file.path}" + expect(doc.css('a')[0].attr('href')).to eq(full_path) + expect(doc.css('img')[0].attr('class')).to eq('gfm lazy') + expect(doc.css('img')[0].attr('data-src')).to eq(full_path) + end + end + end end |