[#792] Add confirmation emails for successful issue replies

This commit is contained in:
Eric Davis 2011-02-02 16:09:11 -08:00
parent d53c4e9aae
commit 7c7aca4f0c
4 changed files with 29 additions and 15 deletions

View File

@ -163,6 +163,7 @@ class MailHandler < ActionMailer::Base
add_attachments(issue)
issue.save!
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
Mailer.deliver_mail_handler_confirmation(issue.last_journal, user, email.subject) if Setting.mail_handler_confirmation_on_success
issue.last_journal
end

View File

@ -287,10 +287,22 @@ class Mailer < ActionMailer::Base
def mail_handler_confirmation(object, user, email_subject)
recipients user.mail
project = object.try(:project).try(:name) || ''
case
when object.is_a?(Issue)
project = object.project.name
url = url_for(:controller => 'issues', :action => 'show', :id => object.id)
when object.is_a?(Journal)
project = object.project.name
url = url_for(:controller => 'issues', :action => 'show', :id => object.issue.id)
else
project = ''
url = ''
end
subject "[#{project}] #{l(:label_mail_handler_confirmation, :subject => email_subject)}"
body(:object => object,
:url => url_for(:controller => 'issues', :action => 'show', :id => object.id))
:url => url)
render_multipart('mail_handler_confirmation', body)
end

View File

@ -818,7 +818,7 @@ en:
label_path_encoding: Path encoding
label_deleted_custom_field: '(deleted custom field)'
label_toc: "Contents"
label_mail_handler_confirmation: "Confirmation of email submission: {{subject}}"
label_mail_handler_confirmation: "Confirmation of email submission: %{subject}"
button_login: Login
button_submit: Submit

View File

@ -1,4 +1,4 @@
#-- encoding: UTF-8
#-- encoding: utf-8 -8
#-- copyright
# ChiliProject is a project management system.
#
@ -304,15 +304,6 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'Feature request', journal.issue.tracker.name
end
test "reply to issue update (Journal) by message_id" do
journal = submit_email('ticket_reply_by_message_id.eml')
assert journal.is_a?(IssueJournal), "Email was a #{journal.class}"
assert_equal User.find_by_login('jsmith'), journal.user
assert_equal Issue.find(2), journal.journaled
assert_match /This is reply/, journal.notes
assert_equal 'Feature request', journal.issue.tracker.name
end
def test_add_issue_note_with_attribute_changes
# This email contains: 'Status: Resolved'
journal = submit_email('ticket_reply_with_status.eml')
@ -336,7 +327,7 @@ class MailHandlerTest < ActiveSupport::TestCase
ActionMailer::Base.deliveries.clear
journal = submit_email('ticket_reply.eml')
assert journal.is_a?(Journal)
assert_equal 3, ActionMailer::Base.deliveries.size
assert_equal 1, ActionMailer::Base.deliveries.size
end
def test_add_issue_note_should_not_set_defaults
@ -474,7 +465,17 @@ class MailHandlerTest < ActiveSupport::TestCase
end
context "#receive_issue_reply" do
should "deliver an email confirmation when configured"
should "deliver an email confirmation when configured" do
journal = submit_email('ticket_reply.eml')
assert_equal 1, ActionMailer::Base.deliveries.size
mail = ActionMailer::Base.deliveries.last
assert_not_nil mail
assert mail.subject.include?('[eCookbook]'), "Project name missing"
assert mail.subject.include?('Confirmation of email submission: Re: Add ingredients categories'), "Main subject missing"
assert mail.body.include?("/issues/2"), "Link to issue missing"
end
end
context "#receive_message_reply" do