Fix error message in extract job

[ci skip]
pull/6641/head
Oliver Günther 6 years ago
parent 714e85ea80
commit 727d081626
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 4
      app/workers/extract_fulltext_job.rb
  2. 4
      spec/workers/extract_fulltext_job_spec.rb

@ -59,9 +59,9 @@ class ExtractFulltextJob < ApplicationJob
@text = resolver.text @text = resolver.text
end end
rescue => e rescue => e
Rails.logger.error { Rails.logger.error(
"Failed to extract plaintext from file #{@attachment.id} (On domain #{Setting.host_name}): #{e}: #{e.message}" "Failed to extract plaintext from file #{@attachment.id} (On domain #{Setting.host_name}): #{e}: #{e.message}"
} )
end end
end end

@ -87,14 +87,14 @@ describe ExtractFulltextJob, type: :job do
end end
context 'with exception in extraction' do context 'with exception in extraction' do
let(:exception_message) { 'boom' } let(:exception_message) { 'boom-internal-error' }
let(:logger) { Rails.logger } let(:logger) { Rails.logger }
before do before do
allow_any_instance_of(Plaintext::Resolver).to receive(:text).and_raise(exception_message) allow_any_instance_of(Plaintext::Resolver).to receive(:text).and_raise(exception_message)
# This line is actually part of the test. `expect` call needs to go so far up here, as we want to verify that a message gets logged. # This line is actually part of the test. `expect` call needs to go so far up here, as we want to verify that a message gets logged.
expect(logger).to receive(:error).with(exception_message) expect(logger).to receive(:error).with(/boom-internal-error/)
allow(attachment).to receive(:readable?).and_return(true) allow(attachment).to receive(:readable?).and_return(true)
attachment.reload attachment.reload

Loading…
Cancel
Save