Improved SVG sanitizer specs to include smoke tests for clean.
This commit is contained in:
parent
a9eaa20dcb
commit
7c87dac5f1
1 changed files with 16 additions and 0 deletions
|
@ -5,6 +5,22 @@ describe Gitlab::Sanitizers::SVG do
|
||||||
let(:namespace) { double(Nokogiri::XML::Namespace, prefix: 'xlink', href: 'http://www.w3.org/1999/xlink') }
|
let(:namespace) { double(Nokogiri::XML::Namespace, prefix: 'xlink', href: 'http://www.w3.org/1999/xlink') }
|
||||||
let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: 'href', namespace: namespace, value: '#awesome_id') }
|
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)
|
||||||
|
described_class.clean(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns sanitized data' do
|
||||||
|
expect(described_class.clean(data)).to eq(sanitized)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'scrubber' do
|
context 'scrubber' do
|
||||||
describe '#scrub' do
|
describe '#scrub' do
|
||||||
let(:invalid_element) { double(Nokogiri::XML::Node, name: 'invalid', value: 'invalid') }
|
let(:invalid_element) { double(Nokogiri::XML::Node, name: 'invalid', value: 'invalid') }
|
||||||
|
|
Loading…
Reference in a new issue