From 512f32f8aabe3f9712a7776d52608bf3afea2969 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 23 Jan 2021 18:17:50 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9activation=20de=20tests=20comment=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/services/email_importer_test.rb | 86 ++++++++++++++-------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/test/services/email_importer_test.rb b/test/services/email_importer_test.rb index 843a382..8610e33 100644 --- a/test/services/email_importer_test.rb +++ b/test/services/email_importer_test.rb @@ -20,48 +20,48 @@ class EmailImporterTest < ActiveSupport::TestCase 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") - # - # expected = /Type: Health and Safety/ - # - # assert_match(expected, email.plain_body) - # assert_no_html email.plain_body - # end - # - # test "single delivered-to" do - # email = email_from_eml("delivered_to_single.eml") - # - # expected = ["delivered-to-1@example.com"] - # actual = email.delivered_to - # - # assert_equal expected, actual - # end - # - # test "multiple delivered-to" do - # email = email_from_eml("delivered_to_multiple.eml") - # - # expected = ["delivered-to-1@example.com", "delivered-to-2@example.com", "delivered-to-3@example.com"] - # actual = email.delivered_to - # - # assert_equal expected, actual - # end - # - # test "missing delivered-to fallback to To field" do - # email = email_from_eml("delivered_to_missing.eml") - # - # expected = ["to-foo@example.com"] - # actual = email.delivered_to - # - # 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 + test "convert html to text when base64-encoded html only" do + email = email_from_eml("html_only_base64.eml") + + expected = /Type: Health and Safety/ + + assert_match(expected, email.plain_body) + assert_no_html email.plain_body + end + + test "single delivered-to" do + email = email_from_eml("delivered_to_single.eml") + + expected = ["delivered-to-1@example.com"] + actual = email.delivered_to + + assert_equal expected, actual + end + + test "multiple delivered-to" do + email = email_from_eml("delivered_to_multiple.eml") + + expected = ["delivered-to-1@example.com", "delivered-to-2@example.com", "delivered-to-3@example.com"] + actual = email.delivered_to + + assert_equal expected, actual + end + + test "missing delivered-to fallback to To field" do + email = email_from_eml("delivered_to_missing.eml") + + expected = ["to-foo@example.com"] + actual = email.delivered_to + + 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