[#792] Add confirmation emails for successful issue creation
This commit is contained in:
parent
9d8fc86b8e
commit
d53c4e9aae
|
@ -141,6 +141,7 @@ class MailHandler < ActionMailer::Base
|
||||||
issue.save!
|
issue.save!
|
||||||
add_attachments(issue)
|
add_attachments(issue)
|
||||||
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
|
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
|
issue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,15 @@ class Mailer < ActionMailer::Base
|
||||||
render_multipart('register', body)
|
render_multipart('register', body)
|
||||||
end
|
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)
|
def test(user)
|
||||||
redmine_headers 'Type' => "Test"
|
redmine_headers 'Type' => "Test"
|
||||||
set_language_if_valid(user.language)
|
set_language_if_valid(user.language)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<p><%= l(:text_mail_handler_confirmation_successful) %><br />
|
||||||
|
<%= auto_link(@url) %></p>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<%= l(:text_mail_handler_confirmation_successful) %>
|
||||||
|
<%= @url %>
|
|
@ -818,6 +818,7 @@ en:
|
||||||
label_path_encoding: Path encoding
|
label_path_encoding: Path encoding
|
||||||
label_deleted_custom_field: '(deleted custom field)'
|
label_deleted_custom_field: '(deleted custom field)'
|
||||||
label_toc: "Contents"
|
label_toc: "Contents"
|
||||||
|
label_mail_handler_confirmation: "Confirmation of email submission: {{subject}}"
|
||||||
|
|
||||||
button_login: Login
|
button_login: Login
|
||||||
button_submit: Submit
|
button_submit: Submit
|
||||||
|
@ -943,6 +944,7 @@ en:
|
||||||
text_git_repo_example: "a bare and local repository (e.g. /gitrepo, c:\\gitrepo)"
|
text_git_repo_example: "a bare and local repository (e.g. /gitrepo, c:\\gitrepo)"
|
||||||
text_display_subprojects: Display subprojects
|
text_display_subprojects: Display subprojects
|
||||||
text_current_project: Current project
|
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_manager: Manager
|
||||||
default_role_developer: Developer
|
default_role_developer: Developer
|
||||||
|
|
|
@ -39,6 +39,8 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||||
def setup
|
def setup
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
|
Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
|
||||||
|
Setting.mail_handler_confirmation_on_success = true
|
||||||
|
Setting.mail_handler_confirmation_on_failure = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_issue
|
def test_add_issue
|
||||||
|
@ -67,6 +69,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||||
assert !issue.description.match(/^Status:/i)
|
assert !issue.description.match(/^Status:/i)
|
||||||
assert !issue.description.match(/^Start Date:/i)
|
assert !issue.description.match(/^Start Date:/i)
|
||||||
# Email notification should be sent
|
# Email notification should be sent
|
||||||
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert_not_nil mail
|
assert_not_nil mail
|
||||||
assert mail.subject.include?('New ticket on a given project')
|
assert mail.subject.include?('New ticket on a given project')
|
||||||
|
@ -289,7 +292,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||||
# This email contains: 'Project: onlinestore'
|
# This email contains: 'Project: onlinestore'
|
||||||
issue = submit_email('ticket_on_given_project.eml')
|
issue = submit_email('ticket_on_given_project.eml')
|
||||||
assert issue.is_a?(Issue)
|
assert issue.is_a?(Issue)
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_issue_note
|
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]
|
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
|
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
|
private
|
||||||
|
|
||||||
def submit_email(filename, options={})
|
def submit_email(filename, options={})
|
||||||
|
|
Loading…
Reference in New Issue