quote_content_spec.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe HtmlSanitizer::Scrubber::QuoteContent do
  4. let(:scrubber) { described_class.new }
  5. describe('#scrubber') do
  6. subject(:actual) do
  7. # export with extra options to avoid html indentation
  8. fragment.scrub!(scrubber)
  9. .to_html save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML ^ Nokogiri::XML::Node::SaveOptions::FORMAT
  10. end
  11. before do
  12. allow(Rails.application.config)
  13. .to receive(:html_sanitizer_tags_quote_content)
  14. .and_return(%w[tag-to-quote])
  15. end
  16. let(:fragment) { Loofah.fragment(input) }
  17. context 'when tag-to-quote div' do
  18. let(:input) { '<tag-to-quote><div>&amp;content</div></tag-to-quote>' }
  19. let(:target) { '&amp;content' }
  20. it { is_expected.to eq target }
  21. end
  22. context 'when div' do
  23. let(:input) { '<div>&amp;content</div>' }
  24. let(:target) { '<div>&amp;content</div>' }
  25. it { is_expected.to eq target }
  26. end
  27. end
  28. end