From 6052df14bab5fe82cd5ccf1979dbfc6d6ab3befa Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 4 Dec 2012 10:35:22 +0000 Subject: Add methods for finding out if there is an empty return path on a mail and getting the auto-submitted field. --- spec/lib/mail_handler/mail_handler_spec.rb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'spec/lib/mail_handler/mail_handler_spec.rb') diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb index 4603b695f..e673c5bf0 100644 --- a/spec/lib/mail_handler/mail_handler_spec.rb +++ b/spec/lib/mail_handler/mail_handler_spec.rb @@ -106,3 +106,35 @@ describe 'when asked for all the addresses a mail has been sent to' do MailHandler.get_all_addresses(mail).should == ["request-5555-xxxxxxxx@whatdotheyknow.com"] end end + +describe 'when asked for auto_submitted' do + + it 'should return a string value for an email with an auto-submitted header' do + mail = get_fixture_mail('autoresponse-header.email') + MailHandler.get_auto_submitted(mail).should == 'auto-replied' + end + + it 'should return a nil value for an email with no auto-submitted header' do + mail = get_fixture_mail('incoming-request-plain.email') + MailHandler.get_auto_submitted(mail).should == nil + end + +end + +describe 'when asked if there is an empty return path' do + + it 'should return true if there is an empty return-path specified' do + mail = get_fixture_mail('empty-return-path.email') + MailHandler.empty_return_path?(mail).should == true + end + + it 'should return false if there is no return-path header' do + mail = get_fixture_mail('incoming-request-attach-attachments.email') + MailHandler.empty_return_path?(mail).should == false + end + + it 'should return false if there is a return path address' do + mail = get_fixture_mail('autoresponse-header.email') + MailHandler.empty_return_path?(mail).should == false + end +end -- cgit v1.2.3