diff options
| -rw-r--r-- | app/models/info_request.rb | 7 | ||||
| -rw-r--r-- | spec/mailers/request_mailer_spec.rb | 18 | 
2 files changed, 24 insertions, 1 deletions
| diff --git a/app/models/info_request.rb b/app/models/info_request.rb index f75d43010..c203f75c3 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -461,7 +461,12 @@ public              # If its not allowing responses, handle the message              if !allow                  if self.handle_rejected_responses == 'bounce' -                    RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external? +                    if MailHandler.get_from_address(email).nil? +                        # do nothing – can't bounce the mail as there's no +                        # address to send it to +                    else +                        RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external? +                    end                  elsif self.handle_rejected_responses == 'holding_pen'                      InfoRequest.holding_pen_request.receive(email, raw_email_data, false, reason)                  elsif self.handle_rejected_responses == 'blackhole' diff --git a/spec/mailers/request_mailer_spec.rb b/spec/mailers/request_mailer_spec.rb index 83befc4b4..a26be866e 100644 --- a/spec/mailers/request_mailer_spec.rb +++ b/spec/mailers/request_mailer_spec.rb @@ -184,6 +184,24 @@ describe RequestMailer, " when receiving incoming mail" do          deliveries.clear      end +    it "discards rejected responses with a malformed From: when set to bounce" do +        ir = info_requests(:fancy_dog_request) +        ir.allow_new_responses_from = 'nobody' +        ir.handle_rejected_responses = 'bounce' +        ir.save! +        ir.incoming_messages.size.should == 1 + +        receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "") +        ir.incoming_messages.size.should == 1 + +        last_event = ir.info_request_events.last +        last_event.params[:rejected_reason].should =~ /there is no "From" address/ + +        deliveries = ActionMailer::Base.deliveries +        deliveries.size.should == 0 +        deliveries.clear +    end +      it "should send all new responses to holding pen if a request is marked to do so" do          # mark request as anti-spam          ir = info_requests(:fancy_dog_request) | 
