Skip to content

Commit

Permalink
Prevent NoMethodError on Mail#bounced? for emails without multipart o…
Browse files Browse the repository at this point in the history
…r delivery_status_part
  • Loading branch information
tmm1 committed Jan 25, 2010
1 parent ea11a63 commit d4e408a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/mail/message.rb
Expand Up @@ -1300,31 +1300,31 @@ def delivery_status_part
end

def bounced?
delivery_status_part.bounced?
delivery_status_part and delivery_status_part.bounced?
end

def action
delivery_status_part.action
delivery_status_part and delivery_status_part.action
end

def final_recipient
delivery_status_part.final_recipient
delivery_status_part and delivery_status_part.final_recipient
end

def error_status
delivery_status_part.error_status
delivery_status_part and delivery_status_part.error_status
end

def diagnostic_code
delivery_status_part.diagnostic_code
delivery_status_part and delivery_status_part.diagnostic_code
end

def remote_mta
delivery_status_part.remote_mta
delivery_status_part and delivery_status_part.remote_mta
end

def retryable?
delivery_status_part.retryable?
delivery_status_part and delivery_status_part.retryable?
end

# Returns the current boundary for this message part
Expand Down
6 changes: 5 additions & 1 deletion spec/mail/message_spec.rb
Expand Up @@ -31,7 +31,11 @@ def basic_email
mail.header.class.should == Mail::Header
mail.body.class.should == Mail::Body
end


it "should not report basic emails as bounced" do
Mail::Message.new.should_not be_bounced
end

it "should be able to parse a basic email" do
doing { Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'basic_email.eml'))) }.should_not raise_error
end
Expand Down

0 comments on commit d4e408a

Please sign in to comment.