From a9eaa20dcb3da119a2d5f2efca615f2273533015 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Fri, 3 Jun 2016 16:08:43 -0300 Subject: Refactored SVG sanitizer --- spec/lib/gitlab/sanitizers/svg_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec/lib/gitlab/sanitizers') diff --git a/spec/lib/gitlab/sanitizers/svg_spec.rb b/spec/lib/gitlab/sanitizers/svg_spec.rb index 061b759bac0..e1b040d6c64 100644 --- a/spec/lib/gitlab/sanitizers/svg_spec.rb +++ b/spec/lib/gitlab/sanitizers/svg_spec.rb @@ -56,5 +56,23 @@ describe Gitlab::Sanitizers::SVG do expect(scrubber.unsafe_href?(namespaced_attr)).to be_falsey end end + + describe '#data_attribute?' do + let(:data_attr) { double(Nokogiri::XML::Attr, name: 'data-gitlab', namespace: nil, value: 'gitlab is awesome') } + let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: 'data-gitlab', namespace: namespace, value: 'gitlab is awesome') } + let(:other_attr) { double(Nokogiri::XML::Attr, name: 'something', namespace: nil, value: 'content') } + + it 'returns true if is a valid data attribute' do + expect(scrubber.data_attribute?(data_attr)).to be_truthy + end + + it 'returns false if attribute is namespaced' do + expect(scrubber.data_attribute?(namespaced_attr)).to be_falsey + end + + it 'returns false if not a data attribute' do + expect(scrubber.data_attribute?(other_attr)).to be_falsey + end + end end end -- cgit v1.2.3