From 23f9e3fe84e33234cdec8f61775a847a23f92a2f Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Thu, 11 Oct 2012 12:39:46 +1100 Subject: Added tests for MailServerLog.email_addresses_on_line --- spec/models/mail_server_log_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec/models/mail_server_log_spec.rb') 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=", -- cgit v1.2.3