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

reference_filter_shared_examples.rb « filters « banzai « lib « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b1ecd4fd00786183fba5be89b7579fedd68229db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

RSpec.shared_examples 'HTML text with references' do
  let(:markdown_prepend) { "<img src=\"\" onerror=alert(`bug`)>" }

  it 'preserves escaped HTML text and adds valid references' do
    reference = resource.to_reference(format: :name)

    doc = reference_filter("#{markdown_prepend}#{reference}")

    expect(doc.to_html).to start_with(markdown_prepend)
    expect(doc.text).to eq %(<img src="" onerror=alert(`bug`)>#{resource_text})
  end

  it 'preserves escaped HTML text if there are no valid references' do
    reference = "#{resource.class.reference_prefix}invalid"
    text = "#{markdown_prepend}#{reference}"

    doc = reference_filter(text)

    expect(doc.to_html).to eq text
  end
end