process_unprocessable_articles_spec.rb 988 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Channel::EmailParser#reprocess_failed_articles', aggregate_failures: true, type: :model do
  4. context 'when receiving unprocessable article' do
  5. before do
  6. allow_any_instance_of(HtmlSanitizer::Strict).to receive(:run_sanitization).and_raise(Timeout::Error, HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
  7. parser = Channel::EmailParser.new
  8. begin
  9. parser.process({}, File.read('test/data/mail/mail001.box'))
  10. rescue
  11. # expected
  12. end
  13. end
  14. it 'does reprocess the unprocessable article' do
  15. expect(Ticket::Article.last.body).to eq(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
  16. allow_any_instance_of(HtmlSanitizer::Strict).to receive(:run_sanitization).and_call_original
  17. Channel::EmailParser.reprocess_failed_articles
  18. expect(Ticket::Article.last.body).not_to eq(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
  19. end
  20. end
  21. end