[#792] Add confirmation emails for successful issue creation

This commit is contained in:
Eric Davis 2011-02-02 15:57:26 -08:00
parent 9d8fc86b8e
commit d53c4e9aae
6 changed files with 44 additions and 3 deletions

View File

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

View File

@ -285,6 +285,15 @@ class Mailer < ActionMailer::Base
render_multipart('register', body)
end
def mail_handler_confirmation(object, user, email_subject)
recipients user.mail
project = object.try(:project).try(:name) || ''
subject "[#{project}] #{l(:label_mail_handler_confirmation, :subject => email_subject)}"
body(:object => object,
:url => url_for(:controller => 'issues', :action => 'show', :id => object.id))
render_multipart('mail_handler_confirmation', body)
end
def test(user)
redmine_headers 'Type' => "Test"
set_language_if_valid(user.language)

View File

@ -0,0 +1,2 @@
<p><%= l(:text_mail_handler_confirmation_successful) %><br />
<%= auto_link(@url) %></p>

View File

@ -0,0 +1,2 @@
<%= l(:text_mail_handler_confirmation_successful) %>
<%= @url %>

View File

@ -818,7 +818,8 @@ 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}}"
button_login: Login
button_submit: Submit
button_save: Save
@ -943,7 +944,8 @@ en:
text_git_repo_example: "a bare and local repository (e.g. /gitrepo, c:\\gitrepo)"
text_display_subprojects: Display subprojects
text_current_project: Current project
text_mail_handler_confirmation_successful: "Your email has been successful added at the following url"
default_role_manager: Manager
default_role_developer: Developer
default_role_reporter: Reporter

View File

@ -39,6 +39,8 @@ class MailHandlerTest < ActiveSupport::TestCase
def setup
ActionMailer::Base.deliveries.clear
Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
Setting.mail_handler_confirmation_on_success = true
Setting.mail_handler_confirmation_on_failure = true
end
def test_add_issue
@ -67,6 +69,7 @@ class MailHandlerTest < ActiveSupport::TestCase
assert !issue.description.match(/^Status:/i)
assert !issue.description.match(/^Start Date:/i)
# Email notification should be sent
assert_equal 2, ActionMailer::Base.deliveries.size
mail = ActionMailer::Base.deliveries.last
assert_not_nil mail
assert mail.subject.include?('New ticket on a given project')
@ -289,7 +292,7 @@ class MailHandlerTest < ActiveSupport::TestCase
# This email contains: 'Project: onlinestore'
issue = submit_email('ticket_on_given_project.eml')
assert issue.is_a?(Issue)
assert_equal 1, ActionMailer::Base.deliveries.size
assert_equal 2, ActionMailer::Base.deliveries.size
end
def test_add_issue_note
@ -456,6 +459,28 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal issue.subject, 'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[0,255]
end
context "#receive_issue" do
should "deliver an email confirmation when configured" do
ActionMailer::Base.deliveries.clear
issue = submit_email('ticket_on_given_project.eml')
assert_equal 2, ActionMailer::Base.deliveries.size
mail = ActionMailer::Base.deliveries.last
assert_not_nil mail
assert mail.subject.include?('[OnlineStore]'), "Project name missing"
assert mail.subject.include?('Confirmation of email submission: New ticket on a given project'), "Main subject missing"
assert mail.body.include?("/issues/#{issue.reload.id}"), "Link to issue missing"
end
end
context "#receive_issue_reply" do
should "deliver an email confirmation when configured"
end
context "#receive_message_reply" do
should "deliver an email confirmation when configured"
end
private
def submit_email(filename, options={})