Welcome to mirror list, hosted at ThFree Co, Russian Federation.

external_link_filter_spec.rb « filter « markdown « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20d37e0c9783ee00494e30b6e158bedc001035ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'

describe Gitlab::Markdown::ExternalLinkFilter do
  include FilterSpecHelper

  it 'ignores elements without an href attribute' do
    exp = act = %q(<a id="ignored">Ignore Me</a>)
    expect(filter(act).to_html).to eq exp
  end

  it 'ignores non-HTTP(S) links' do
    exp = act = %q(<a href="irc://irc.freenode.net/gitlab">IRC</a>)
    expect(filter(act).to_html).to eq exp
  end

  it 'skips internal links' do
    internal = Gitlab.config.gitlab.url
    exp = act = %Q(<a href="#{internal}/sign_in">Login</a>)
    expect(filter(act).to_html).to eq exp
  end

  it 'adds rel="nofollow" to external links' do
    act = %q(<a href="https://google.com/">Google</a>)
    doc = filter(act)

    expect(doc.at_css('a')).to have_attribute('rel')
    expect(doc.at_css('a')['rel']).to eq 'nofollow'
  end
end