Un mail peut ne pas avoir de content_type
This commit is contained in:
parent
dbbe37ae61
commit
d5a3f11137
|
@ -45,10 +45,10 @@ class EmailImporter
|
|||
else
|
||||
mail.parts[0].decoded
|
||||
end
|
||||
elsif mail.content_type.match?(/text\/html/)
|
||||
Nokogiri::HTML(mail.body.decoded).text
|
||||
elsif mail.content_type && mail.content_type.match?(/text\/html/)
|
||||
Nokogiri::HTML(mail.decoded).text
|
||||
else
|
||||
mail.body.decoded
|
||||
mail.decoded
|
||||
end
|
||||
end
|
||||
|
||||
|
|
28
test/fixtures/files/no_content_type.eml
vendored
Normal file
28
test/fixtures/files/no_content_type.eml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
Return-Path: <return-path@example.com>
|
||||
Delivered-To: delivered-to-1@example.com
|
||||
Received: by mx.example.com (Postfix, from userid 1000)
|
||||
id 8B3187F5D3; Sat, 12 Sep 2020 06:43:04 +0200 (CEST)
|
||||
From: from-foo@example.com
|
||||
To: Foo <to-foo@example.com>
|
||||
Subject: Cron Dummy subject
|
||||
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
||||
Message-Id: <no-content-type@example.com>
|
||||
|
||||
This is a RAID status update from megaraidsas-statusd. The megaraidsas-status
|
||||
program reports that one of the RAIDs changed state:
|
||||
|
||||
-- Arrays informations --
|
||||
-- ID | Type | Size | Status
|
||||
a0d0 | RAID 1 | 476GiB | optimal
|
||||
a0d1 | RAID 1 | 278GiB | optimal
|
||||
|
||||
-- Disks informations
|
||||
-- ID | Model | Status | Warnings
|
||||
a0e32s0 | ATA KINGSTON SKC6005 476GiB | online | errs: media:0 other:6 predictive-failure
|
||||
a0e32s1 | ATA SAMSUNG MZ7LN512 476GiB a0d0 | predictive-failure
|
||||
a0e32s2 | SEAGATE ST3300657SS 279GiB | online
|
||||
a0e32s3 | SEAGATE ST3300657SS 279GiB | online
|
||||
|
||||
There is at least one disk/array in a NOT OPTIMAL state.
|
||||
|
||||
Report from /etc/init.d/megaraidsas-statusd on kampn-kvm00
|
|
@ -102,4 +102,12 @@ class EmailImporterTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
test "mail without content-type" do
|
||||
email = email_from_eml("no_content_type.eml")
|
||||
|
||||
expected = /This is a RAID status update from megaraidsas-statusd/
|
||||
|
||||
assert_match(expected, email.plain_body)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue