From b9c785535a020c0bc1b871bca48cee71aa2143d9 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Wed, 7 Sep 2011 20:52:44 +0100 Subject: Detect multipart/report bounce messages Add support for multipart/report bounce messages to script/handle-mail-replies. Also add a spec test for this script. --- spec/script/handle-mail-replies_spec.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/script/handle-mail-replies_spec.rb (limited to 'spec/script/handle-mail-replies_spec.rb') diff --git a/spec/script/handle-mail-replies_spec.rb b/spec/script/handle-mail-replies_spec.rb new file mode 100644 index 000000000..856476c3f --- /dev/null +++ b/spec/script/handle-mail-replies_spec.rb @@ -0,0 +1,33 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require "external_command" + +def mail_reply_test(email_filename) + Dir.chdir RAILS_ROOT do + xc = ExternalCommand.new("script/handle-mail-replies", "--test") + xc.run(load_file_fixture(email_filename)) + + xc.err.should == "" + return xc + end +end + +describe "When filtering" do + it "should detect an Exim bounce" do + r = mail_reply_test("track-response-exim-bounce.email") + r.status.should == 1 + r.out.should == "user@example.com\n" + end + + it "should pass on a non-bounce message" do + r = mail_reply_test("incoming-request-bad-uuencoding.email") + r.status.should == 0 + r.out.should == "" + end + + it "should detect a multipart bounce" do + r = mail_reply_test("track-response-multipart-report.email") + r.status.should == 1 + r.out.should == "FailedUser@example.com\n" + end +end + -- cgit v1.2.3