aboutsummaryrefslogtreecommitdiffstats
path: root/spec/script/handle-mail-replies_spec.rb
blob: 856476c3f132d1c354ff603eef4759a618db4d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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