From 331ecb4c4f79ff4049dd4ab5db91d3f14b3ef576 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 2 Feb 2011 16:16:17 -0800 Subject: [PATCH] [#792] Add confirmation emails for successful forum replies --- app/models/mail_handler.rb | 1 + app/models/mailer.rb | 3 +++ test/unit/mail_handler_test.rb | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 6ed1fe97..5deb1683 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -192,6 +192,7 @@ class MailHandler < ActionMailer::Base reply.board = message.board message.children << reply add_attachments(reply) + Mailer.deliver_mail_handler_confirmation(message, user, reply.subject) if Setting.mail_handler_confirmation_on_success reply else logger.info "MailHandler: ignoring reply from [#{sender_email}] to a locked topic" if logger && logger.info diff --git a/app/models/mailer.rb b/app/models/mailer.rb index efbe8821..dfb5119f 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -295,6 +295,9 @@ class Mailer < ActionMailer::Base when object.is_a?(Journal) project = object.project.name url = url_for(:controller => 'issues', :action => 'show', :id => object.issue.id) + when object.class == Message + project = object.project.name + url = url_for(object.event_url) else project = '' url = '' diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 3deabac0..6fb8cd0c 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -479,7 +479,17 @@ class MailHandlerTest < ActiveSupport::TestCase end context "#receive_message_reply" do - should "deliver an email confirmation when configured" + should "deliver an email confirmation when configured" do + ActionMailer::Base.deliveries.clear + m = submit_email('message_reply.eml') + + assert_equal 2, 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: Reply via email'), "Main subject missing" + assert mail.body.include?("/boards/1/topics/1"), "Link to message missing" + end end private