[#792] Send email from mail_handler for emails which are missing required information
This commit is contained in:
parent
1dd07471ca
commit
dc541597ec
|
@ -103,6 +103,7 @@ class MailHandler < ActionMailer::Base
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
# TODO: send a email to the user
|
# TODO: send a email to the user
|
||||||
logger.error e.message if logger
|
logger.error e.message if logger
|
||||||
|
Mailer.deliver_mail_handler_missing_information(user, email.subject.to_s, e.message) if Setting.mail_handler_confirmation_on_failure
|
||||||
false
|
false
|
||||||
rescue MissingInformation => e
|
rescue MissingInformation => e
|
||||||
logger.error "MailHandler: missing information from #{user}: #{e.message}" if logger
|
logger.error "MailHandler: missing information from #{user}: #{e.message}" if logger
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
Return-Path: <JSmith@somenet.foo>
|
||||||
|
Received: from osiris ([127.0.0.1])
|
||||||
|
by OSIRIS
|
||||||
|
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||||
|
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||||
|
From: "John Smith" <JSmith@somenet.foo>
|
||||||
|
To: <redmine@somenet.foo>
|
||||||
|
Subject: New ticket on a given project
|
||||||
|
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain;
|
||||||
|
format=flowed;
|
||||||
|
charset="iso-8859-1";
|
||||||
|
reply-type=original
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
X-Priority: 3
|
||||||
|
X-MSMail-Priority: Normal
|
||||||
|
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||||
|
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||||
|
|
||||||
|
Test with missing information
|
||||||
|
|
||||||
|
Project: onlinestore
|
|
@ -497,6 +497,25 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||||
assert mail.body.include?('Unable to determine target project')
|
assert mail.body.include?('Unable to determine target project')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "deliver an email error confirmation to the sender for a missing other attributes" do
|
||||||
|
# Add a required custom field to simulate the error
|
||||||
|
project = Project.find('onlinestore')
|
||||||
|
project.issue_custom_fields << IssueCustomField.generate(:name => 'Required Custom Field0', :is_required => true, :trackers => project.trackers)
|
||||||
|
project.save
|
||||||
|
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
issue = submit_email('ticket_on_project_with_missing_information.eml')
|
||||||
|
assert_equal false, issue
|
||||||
|
|
||||||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
|
mail = ActionMailer::Base.deliveries.last
|
||||||
|
assert_not_nil mail
|
||||||
|
assert mail.bcc.include?('jsmith@somenet.foo')
|
||||||
|
assert mail.subject.include?('Failed email submission: New ticket on a given project')
|
||||||
|
assert mail.body.include?('There were errors with your email submission')
|
||||||
|
assert mail.body.include?('Required Custom Field0 can\'t be blank')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#receive_issue" do
|
context "#receive_issue" do
|
||||||
|
|
Loading…
Reference in New Issue