diff options
author | Gabriel Mazetto <gabriel@gitlab.com> | 2016-06-09 08:51:40 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-06-13 04:05:58 +0300 |
commit | 7c87dac5f1f3d333b06dbcb2c7f66538abfb8255 (patch) | |
tree | 255e995c6205562ea561266e6849823654eed8c1 /spec/lib | |
parent | a9eaa20dcb3da119a2d5f2efca615f2273533015 (diff) |
Improved SVG sanitizer specs to include smoke tests for clean.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/sanitizers/svg_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sanitizers/svg_spec.rb b/spec/lib/gitlab/sanitizers/svg_spec.rb index e1b040d6c64..030c2063ab2 100644 --- a/spec/lib/gitlab/sanitizers/svg_spec.rb +++ b/spec/lib/gitlab/sanitizers/svg_spec.rb @@ -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(: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 describe '#scrub' do let(:invalid_element) { double(Nokogiri::XML::Node, name: 'invalid', value: 'invalid') } |