Commit 7c87dac5 authored by Gabriel Mazetto's avatar Gabriel Mazetto Committed by Robert Speicher
Browse files

Improved SVG sanitizer specs to include smoke tests for clean.

parent fe058ecc4629
......@@ -5,6 +5,22 @@
let(:namespace) { double(Nokogiri::XML::Namespace, prefix: 'xlink', href: '') }
let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: 'href', namespace: namespace, value: '#awesome_id') }
describe '.clean' do
let(:input_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'unsanitized.svg') }
let(:data) { open(input_svg_path).read }
let(:sanitized_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'sanitized.svg') }
let(:sanitized) { open(sanitized_svg_path).read }
it 'delegates sanitization to scrubber' do
expect_any_instance_of(Gitlab::Sanitizers::SVG::Scrubber).to receive(:scrub).at_least(:once)
it 'returns sanitized data' do
expect(described_class.clean(data)).to eq(sanitized)
context 'scrubber' do
describe '#scrub' do
let(:invalid_element) { double(Nokogiri::XML::Node, name: 'invalid', value: 'invalid') }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment