aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2012-10-11 12:39:46 +1100
committerMatthew Landauer <matthew@openaustralia.org>2012-10-11 12:39:46 +1100
commit23f9e3fe84e33234cdec8f61775a847a23f92a2f (patch)
treec255b1fc319613cea07f7e3ae3beb0e6a88df1e9
parentb2a034dad3d0ad449f0a7c9c963aee13c2f93c20 (diff)
Added tests for MailServerLog.email_addresses_on_line
-rw-r--r--spec/models/mail_server_log_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/mail_server_log_spec.rb b/spec/models/mail_server_log_spec.rb
index cad64f7ff..f4de7ee68 100644
--- a/spec/models/mail_server_log_spec.rb
+++ b/spec/models/mail_server_log_spec.rb
@@ -62,6 +62,26 @@ describe MailServerLog do
end
end
+ describe ".email_addresses_on_line" do
+ before :each do
+ Configuration.stub!(:incoming_email_domain).and_return("example.com")
+ end
+
+ it "recognises a single incoming email" do
+ MailServerLog.email_addresses_on_line("a random log line foi+request-14-e0e09f97@example.com has an email").should ==
+ ["request-14-e0e09f97@example.com"]
+ end
+
+ it "recognises two email addresses on the same line" do
+ MailServerLog.email_addresses_on_line("two email addresses here foi+request-10-1234@example.com and foi+request-14-e0e09f97@example.com").should ==
+ ["request-10-1234@example.com", "request-14-e0e09f97@example.com"]
+ end
+
+ it "returns an empty array when there is an email address from a different domain" do
+ MailServerLog.email_addresses_on_line("other foi+request-10-1234@foo.com").should be_empty
+ end
+ end
+
context "Postfix" do
let(:log) {[
"Oct 3 16:39:35 host postfix/pickup[2257]: CB55836EE58C: uid=1003 from=<foitest+request-14-e0e09f97@example.com>",