diff options
| author | Rémy Coutable <remy@rymai.me> | 2016-07-12 19:31:20 +0200 |
|---|---|---|
| committer | Rémy Coutable <remy@rymai.me> | 2016-07-19 18:51:09 +0200 |
| commit | 98e540532cc2706e4cdc027bd2acb8406e954ddc (patch) | |
| tree | 92f4157e6a50ae72ead3ccf60cf6a035fefc7f3b /spec | |
| parent | 29ea8d09e05d749f0b6a784311aea942f7d2d0f1 (diff) | |
| download | gitlab-ce-98e540532cc2706e4cdc027bd2acb8406e954ddc.tar.gz | |
Use a more powerful query to match videos in img tags
Also, always add a link to download videos since video playback is
tricky. Also, it solves the issue with email client not supporting
videos.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/banzai/filter/video_link_filter_spec.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/spec/lib/banzai/filter/video_link_filter_spec.rb b/spec/lib/banzai/filter/video_link_filter_spec.rb index 8ccfb9c0fca..bdf76c458b0 100644 --- a/spec/lib/banzai/filter/video_link_filter_spec.rb +++ b/spec/lib/banzai/filter/video_link_filter_spec.rb @@ -9,28 +9,34 @@ describe Banzai::Filter::VideoLinkFilter, lib: true do described_class.call(doc, contexts) end - def image(path) + def link_to_image(path) %(<img src="#{path}" />) end let(:project) { create(:project) } context 'when the element src has a video extension' do - it 'replaces the image tag with a video tag' do - doc = filter(image("/path/video.mov")) - element = doc.children.first - expect(element.name).to eq( "video" ) - expect(element['src']).to eq( "/path/video.mov" ) + UploaderHelper::VIDEO_EXT.each do |ext| + it "replaces the image tag 'path/video.#{ext}' with a video tag" do + element = filter(link_to_image("/path/video.#{ext}")).children.first + + expect(element.name).to eq 'video' + expect(element['src']).to eq "/path/video.#{ext}" + + fallback_link = element.children.first + expect(fallback_link.name).to eq 'a' + expect(fallback_link['href']).to eq "/path/video.#{ext}" + expect(fallback_link['target']).to eq '_blank' + end end end context 'when the element src is an image' do it 'leaves the document unchanged' do - doc = filter(image("/path/my_image.jpg")) - element = doc.children.first - expect(element.name).to eq( "img" ) + element = filter(link_to_image("/path/my_image.jpg")).children.first + + expect(element.name).to eq 'img' end end - end |
