diff options
| author | James Lopez <james@jameslopez.es> | 2016-04-05 09:36:49 +0200 |
|---|---|---|
| committer | James Lopez <james@jameslopez.es> | 2016-04-05 09:36:49 +0200 |
| commit | 850180aa393e2cfc124bb9687a123a196cff734c (patch) | |
| tree | 2d71ff44dd3761f3583fca847c440f08620cad80 /spec/lib | |
| parent | 7f7769172e81dc8bfdb037965ec7bf51c95578ec (diff) | |
| parent | 6bf4e9e75232be83995a09f3a83e47fd0103273f (diff) | |
| download | gitlab-ce-850180aa393e2cfc124bb9687a123a196cff734c.tar.gz | |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/project-import_url
Diffstat (limited to 'spec/lib')
| -rw-r--r-- | spec/lib/banzai/filter/image_link_filter_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/image_link_filter_spec.rb b/spec/lib/banzai/filter/image_link_filter_spec.rb new file mode 100644 index 00000000000..dd5594750c8 --- /dev/null +++ b/spec/lib/banzai/filter/image_link_filter_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe Banzai::Filter::ImageLinkFilter, lib: true do + include FilterSpecHelper + + def image(path) + %(<img src="#{path}" />) + end + + it 'wraps the image with a link to the image src' do + doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) + expect(doc.at_css('img')['src']).to eq doc.at_css('a')['href'] + end + + it 'does not wrap a duplicate link' do + exp = act = %q(<a href="/whatever">#{image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')}</a>) + expect(filter(act).to_html).to eq exp + end + + it 'works with external images' do + doc = filter(image('https://i.imgur.com/DfssX9C.jpg')) + expect(doc.at_css('img')['src']).to eq doc.at_css('a')['href'] + end +end |
