55 lines
1.5 KiB
Ruby
55 lines
1.5 KiB
Ruby
require 'test_helper'
|
|
|
|
class EmailImporterTest < ActiveSupport::TestCase
|
|
test "convert html to text when not multipart html only" do
|
|
email = email_from_eml("html_only.eml")
|
|
|
|
assert_match(/Attention, plus que quelques jours pour bénéficier du FNE !/, email.plain_body)
|
|
assert_no_html email.plain_body
|
|
end
|
|
|
|
test "convert html to text when multipart and html only" do
|
|
email = email_from_eml("html_only_multipart.eml")
|
|
|
|
assert_match(/Complément d''information : suite du ticket 2009P88471/, email.plain_body)
|
|
assert_no_html email.plain_body
|
|
end
|
|
|
|
test "convert html to text when base64-encoded html only" do
|
|
email = email_from_eml("html_only_base64.eml")
|
|
|
|
assert_match(/Type: Health and Safety/, email.plain_body)
|
|
assert_no_html email.plain_body
|
|
end
|
|
|
|
test "mark cron from subject" do
|
|
email = email_from_eml("cron_subject.eml")
|
|
|
|
assert_predicate email, :cron?
|
|
end
|
|
|
|
test "mark cron from headers" do
|
|
email = email_from_eml("cron_headers.eml")
|
|
|
|
assert_predicate email, :cron?
|
|
end
|
|
|
|
test "mark not cron" do
|
|
email = email_from_eml("cron_not.eml")
|
|
|
|
assert_not_predicate email, :cron?
|
|
end
|
|
|
|
test "single delivered-to" do
|
|
email = email_from_eml("delivered_to_single.eml")
|
|
|
|
assert_equal email.delivered_to, "equipe+lpoujol@evolix.fr"
|
|
end
|
|
|
|
test "multiple delivered-to" do
|
|
email = email_from_eml("delivered_to_multiple.eml")
|
|
|
|
assert_equal email.delivered_to, ["equipe@evolix.net", "alert3@evolix.fr", "root@stratis-www01.evolix.net"]
|
|
end
|
|
end
|