1 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
\r
9 it "should be valid" do
\r
10 @mails.should be_valid
\r
13 describe "post_all_mail" do
\r
15 #Net::SMTP = DummySMTP
\r
16 @customer = customers(:valid_signup2)
\r
17 @dummysmtp = DummySMTP.new('localhost')
\r
20 it "should be successful" do
\r
21 @dummysmtp.stub!(:send_message).and_return(nil)
\r
22 Net::SMTP.stub!(:start).and_yield(@dummysmtp)
\r
23 @mail = Mail.new(:to_address => @customer.email,
\r
24 :from_address => "sender@example.com",
\r
27 mails = Mail.find(:all, :conditions => "sent_at is null")
\r
28 mails.should_not == []
\r
30 mails = Mail.find(:all, :conditions => "sent_at is null")
\r
34 it "raise 5xx error" do
\r
35 @customer.reachable.should be_true
\r
36 @dummysmtp.stub!(:send_message).and_raise(Net::SMTPSyntaxError)
\r
37 Net::SMTP.stub!(:start).and_yield(@dummysmtp)
\r
38 @mail = Mail.new(:to_address => @customer.email,
\r
39 :from_address => "sender@example.com",
\r
43 customer = Customer.find(@customer.id)
\r
44 customer.reachable.should be_false
\r
47 it "raise 4xx error" do
\r
48 mail_delivery_count = @customer.mail_delivery_count
\r
49 mail_delivery_count = 1 if mail_delivery_count.nil?
\r
50 @dummysmtp.stub!(:send_message).and_raise(Net::SMTPServerBusy)
\r
51 Net::SMTP.stub!(:start).and_yield(@dummysmtp)
\r
52 @mail = Mail.new(:to_address => @customer.email,
\r
53 :from_address => "sender@example.com",
\r
57 customer = Customer.find(@customer.id)
\r
58 customer.reachable.should be_true
\r
59 customer.mail_delivery_count.should == mail_delivery_count + 1
\r
62 it "over mail_delivery count" do
\r
63 @customer.mail_delivery_count = 5
\r
65 @dummysmtp.stub!(:send_message).and_raise(Net::SMTPServerBusy)
\r
66 Net::SMTP.stub!(:start).and_yield(@dummysmtp)
\r
67 @mail = Mail.new(:to_address => @customer.email,
\r
68 :from_address => "sender@example.com",
\r
72 customer = Customer.find(@customer.id)
\r
73 customer.reachable.should be_false
\r
80 def initialize(address, port = nil)
\r
83 def send_message(message, from, to)
\r