diff options
| author | Rémy Coutable <remy@rymai.me> | 2016-07-12 19:28:39 +0200 |
|---|---|---|
| committer | Rémy Coutable <remy@rymai.me> | 2016-07-20 11:36:42 +0200 |
| commit | 6b7e9c7655e4ffc74de90f01a0850a230b10a03c (patch) | |
| tree | da865eb7dff81588d426907afcc74d6a072fe3fa /spec | |
| parent | 98e540532cc2706e4cdc027bd2acb8406e954ddc (diff) | |
| download | gitlab-ce-6b7e9c7655e4ffc74de90f01a0850a230b10a03c.tar.gz | |
Remove VideoJS and clean the integration
Handle videos in:
- MD preview in notes: commit, issue/MR, MR diff
- New notes in: commit, issue/MR, MR diff
- Persisted notes in: commit, issue/MR, MR diff
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/features/markdown_spec.rb | 12 | ||||
| -rw-r--r-- | spec/fixtures/markdown.md.erb | 4 | ||||
| -rw-r--r-- | spec/lib/banzai/filter/video_link_filter_spec.rb | 25 | ||||
| -rw-r--r-- | spec/support/matchers/markdown_matchers.rb | 11 | ||||
| -rw-r--r-- | spec/uploaders/file_uploader_spec.rb | 59 |
5 files changed, 75 insertions, 36 deletions
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 09ccc77c101..32159559c37 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -236,6 +236,14 @@ describe 'GitLab Markdown', feature: true do it 'includes TaskListFilter' do expect(doc).to parse_task_lists end + + it 'includes InlineDiffFilter' do + expect(doc).to parse_inline_diffs + end + + it 'includes VideoLinkFilter' do + expect(doc).to parse_video_links + end end context 'wiki pipeline' do @@ -293,6 +301,10 @@ describe 'GitLab Markdown', feature: true do it 'includes InlineDiffFilter' do expect(doc).to parse_inline_diffs end + + it 'includes VideoLinkFilter' do + expect(doc).to parse_video_links + end end # Fake a `current_user` helper diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb index c75d28d9801..f3e7c2d1a9f 100644 --- a/spec/fixtures/markdown.md.erb +++ b/spec/fixtures/markdown.md.erb @@ -256,3 +256,7 @@ However the wrapping tags can not be mixed as such - - [+ additions +} - {- delletions -] - [- delletions -} + +### Videos + + diff --git a/spec/lib/banzai/filter/video_link_filter_spec.rb b/spec/lib/banzai/filter/video_link_filter_spec.rb index bdf76c458b0..cc4349f80ba 100644 --- a/spec/lib/banzai/filter/video_link_filter_spec.rb +++ b/spec/lib/banzai/filter/video_link_filter_spec.rb @@ -18,24 +18,33 @@ describe Banzai::Filter::VideoLinkFilter, lib: true do context 'when the element src has a video extension' do 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 + container = filter(link_to_image("/path/video.#{ext}")).children.first - expect(element.name).to eq 'video' - expect(element['src']).to eq "/path/video.#{ext}" + expect(container.name).to eq 'div' + expect(container['class']).to eq 'video-container' - 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' + video, paragraph = container.children + + expect(video.name).to eq 'video' + expect(video['src']).to eq "/path/video.#{ext}" + + expect(paragraph.name).to eq 'p' + + link = paragraph.children.first + + expect(link.name).to eq 'a' + expect(link['href']).to eq "/path/video.#{ext}" + expect(link['target']).to eq '_blank' end end end context 'when the element src is an image' do it 'leaves the document unchanged' do - element = filter(link_to_image("/path/my_image.jpg")).children.first + element = filter(link_to_image('/path/my_image.jpg')).children.first expect(element.name).to eq 'img' + expect(element['src']).to eq '/path/my_image.jpg' end end diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb index e005058ba5b..8c98b1f988c 100644 --- a/spec/support/matchers/markdown_matchers.rb +++ b/spec/support/matchers/markdown_matchers.rb @@ -178,6 +178,17 @@ module MarkdownMatchers expect(actual).to have_selector('span.idiff.deletion', count: 2) end end + + # VideoLinkFilter + matcher :parse_video_links do + set_default_markdown_messages + + match do |actual| + video = actual.at_css('video') + + expect(video['src']).to end_with('/assets/videos/gitlab-demo.mp4') + end + end end # Monkeypatch the matcher DSL so that we can reduce some noisy duplication for diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb index b59f44e0a65..e8300abed5d 100644 --- a/spec/uploaders/file_uploader_spec.rb +++ b/spec/uploaders/file_uploader_spec.rb @@ -1,42 +1,45 @@ -require "spec_helper" - -# provides matchers like `have_dimensions` -# https://github.com/carrierwaveuploader/carrierwave#testing-with-carrierwave -# require "carrierwave/test/matchers" - +require 'spec_helper' describe FileUploader do - # include CarrierWave::Test::Matchers - - let(:project){ create(:project) } - - let(:image_file){ File.new Rails.root.join("spec", "fixtures", "rails_sample.jpg") } - let(:video_file){ File.new Rails.root.join("spec", "fixtures", "video_sample.mp4") } - let(:text_file) { File.new Rails.root.join("spec", "fixtures", "doc_sample.txt") } + let(:project) { create(:project) } before do + @previous_enable_processing = FileUploader.enable_processing FileUploader.enable_processing = false @uploader = FileUploader.new(project) end after do - FileUploader.enable_processing = true + FileUploader.enable_processing = @previous_enable_processing @uploader.remove! end - it "should detect an image based on file extension" do - @uploader.store!(image_file) - expect(@uploader.image_or_video?).to be true + describe '#image_or_video?' do + context 'given an image file' do + before do + @uploader.store!(File.new(Rails.root.join('spec', 'fixtures', 'rails_sample.jpg'))) + end + + it 'detects an image based on file extension' do + expect(@uploader.image_or_video?).to be true + end + end + + context 'given an video file' do + before do + video_file = File.new(Rails.root.join('spec', 'fixtures', 'video_sample.mp4')) + @uploader.store!(video_file) + end + + it 'detects a video based on file extension' do + expect(@uploader.image_or_video?).to be true + end + end + + it 'does not return image_or_video? for other types' do + @uploader.store!(File.new(Rails.root.join('spec', 'fixtures', 'doc_sample.txt'))) + + expect(@uploader.image_or_video?).to be false + end end - - it "should detect a video based on file extension" do - @uploader.store!(video_file) - expect(@uploader.image_or_video?).to be true - end - - it "should not return image_or_video? for other types" do - @uploader.store!(text_file) - expect(@uploader.image_or_video?).to be false - end - end |
