aboutsummaryrefslogtreecommitdiffstats
path: root/spec/script/mailin_spec.rb
blob: 53f4ae125c47a18e0c46780df79acb83f67a2dd5 (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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require "external_command"

def mailin_test(email_filename)
    Dir.chdir Rails.root do
        xc = ExternalCommand.new("script/mailin")
        mail = load_file_fixture(email_filename)
        ir = info_requests(:boring_request)
        mail.gsub!('EMAIL_TO', ir.incoming_email)
        mail.gsub!('EMAIL_FROM', 'geraldinequango@localhost')
        xc.run(mail)
        xc.err.should == ""
        return xc
    end
end

describe "When importing mail into the application" do

    it "should not produce any output and should return a 0 code on importing a plain email" do
        r = mailin_test("incoming-request-plain.email")
        r.status.should == 0
        r.out.should == ""
    end

end