aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-28 11:12:51 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-28 11:12:51 -0700
commitc9d8f6650d6c5c88c5346032b23d037cf3e4aae6 (patch)
treeebdefc715a27150fa2640e95b218131069b63b27 /test
parent456d79b853aaec14f14c4c4deaa04cfb66c5b357 (diff)
downloadrails-c9d8f6650d6c5c88c5346032b23d037cf3e4aae6.tar.gz
rails-c9d8f6650d6c5c88c5346032b23d037cf3e4aae6.tar.bz2
rails-c9d8f6650d6c5c88c5346032b23d037cf3e4aae6.zip
Flesh out testing
Diffstat (limited to 'test')
-rw-r--r--test/unit/inbound_email/message_id_test.rb15
-rw-r--r--test/unit/inbound_email_test.rb9
2 files changed, 21 insertions, 3 deletions
diff --git a/test/unit/inbound_email/message_id_test.rb b/test/unit/inbound_email/message_id_test.rb
new file mode 100644
index 0000000000..75c15a531a
--- /dev/null
+++ b/test/unit/inbound_email/message_id_test.rb
@@ -0,0 +1,15 @@
+require_relative '../../test_helper'
+
+class ActionMailroom::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
+ source_without_message_id = "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!"
+ inbound_email = create_inbound_email Tempfile.new.tap { |raw_email| raw_email.write source_without_message_id }
+
+ assert_not_nil inbound_email.message_id
+ end
+end
diff --git a/test/unit/inbound_email_test.rb b/test/unit/inbound_email_test.rb
index 3eedd60472..e4b7be2440 100644
--- a/test/unit/inbound_email_test.rb
+++ b/test/unit/inbound_email_test.rb
@@ -2,9 +2,12 @@ require_relative '../test_helper'
module ActionMailroom
class InboundEmailTest < 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
+ test "mail provides the parsed source" do
+ assert_equal "Discussion: Let's debate these attachments", create_inbound_email_from_fixture("welcome.eml").mail.subject
+ end
+
+ test "source returns the contents of the raw email" do
+ assert_equal file_fixture("welcome.eml").read, create_inbound_email_from_fixture("welcome.eml").source
end
end
end