has_xss_sanitized_note_examples.rb 405 B

1234567891011
  1. RSpec.shared_examples 'HasXssSanitizedNote' do |model_factory:|
  2. describe 'XSS prevention' do
  3. context 'with injected JS' do
  4. subject { create(model_factory, note: 'test 123 <script type="text/javascript">alert("XSS!");</script> <b>some text</b>') }
  5. it 'strips out <script> tag' do
  6. expect(subject.note).to eq('test 123 alert("XSS!"); <b>some text</b>')
  7. end
  8. end
  9. end
  10. end