diff options
Diffstat (limited to 'actionmailbox/test/unit/inbound_email')
-rw-r--r-- | actionmailbox/test/unit/inbound_email/incineration_test.rb | 47 | ||||
-rw-r--r-- | actionmailbox/test/unit/inbound_email/message_id_test.rb | 15 |
2 files changed, 62 insertions, 0 deletions
diff --git a/actionmailbox/test/unit/inbound_email/incineration_test.rb b/actionmailbox/test/unit/inbound_email/incineration_test.rb new file mode 100644 index 0000000000..21c01a9cea --- /dev/null +++ b/actionmailbox/test/unit/inbound_email/incineration_test.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class ActionMailbox::InboundEmail::IncinerationTest < ActiveSupport::TestCase + test "incinerating 30 days after delivery" do + freeze_time + + assert_enqueued_with job: ActionMailbox::IncinerationJob, at: 30.days.from_now do + create_inbound_email_from_fixture("welcome.eml").delivered! + end + + travel 30.days + + assert_difference -> { ActionMailbox::InboundEmail.count }, -1 do + perform_enqueued_jobs only: ActionMailbox::IncinerationJob + end + end + + test "incinerating 30 days after bounce" do + freeze_time + + assert_enqueued_with job: ActionMailbox::IncinerationJob, at: 30.days.from_now do + create_inbound_email_from_fixture("welcome.eml").bounced! + end + + travel 30.days + + assert_difference -> { ActionMailbox::InboundEmail.count }, -1 do + perform_enqueued_jobs only: ActionMailbox::IncinerationJob + end + end + + test "incinerating 30 days after failure" do + freeze_time + + assert_enqueued_with job: ActionMailbox::IncinerationJob, at: 30.days.from_now do + create_inbound_email_from_fixture("welcome.eml").failed! + end + + travel 30.days + + assert_difference -> { ActionMailbox::InboundEmail.count }, -1 do + perform_enqueued_jobs only: ActionMailbox::IncinerationJob + end + end +end diff --git a/actionmailbox/test/unit/inbound_email/message_id_test.rb b/actionmailbox/test/unit/inbound_email/message_id_test.rb new file mode 100644 index 0000000000..af467a8d45 --- /dev/null +++ b/actionmailbox/test/unit/inbound_email/message_id_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class ActionMailbox::InboundEmail::MessageIdTest < ActiveSupport::TestCase + test "message id is extracted from raw email" do + inbound_email = create_inbound_email_from_fixture("welcome.eml") + assert_equal "0CB459E0-0336-41DA-BC88-E6E28C697DDB@37signals.com", inbound_email.message_id + end + + test "message id is generated if its missing" do + inbound_email = create_inbound_email_from_source "Date: Fri, 28 Sep 2018 11:08:55 -0700\r\nTo: a@example.com\r\nMime-Version: 1.0\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: 7bit\r\n\r\nHello!" + assert_not_nil inbound_email.message_id + end +end |