From 21e503fc7100049131c41d27a33ec62094135263 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 15 Feb 2019 23:52:30 +0000 Subject: Show author's name in the From field of email notifications (#5913). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@17870 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/mailer_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/unit') diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index 37e41e87b..f22f532f4 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -249,6 +249,25 @@ class MailerTest < ActiveSupport::TestCase assert_equal 'Redmine app ', mail.header['From'].to_s end + def test_from_header_with_author_name + # Use the author's name or Setting.app_title as a display name + # when Setting.mail_from does not include a display name + with_settings :mail_from => 'redmine@example.net', :app_title => 'Foo' do + # Use @author.name as a display name + Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 5, + :subject => 'Issue created by Dave Lopper', :author_id => 3) + mail = last_email + assert_equal 'redmine@example.net', mail.from_addrs.first + assert_equal 'Dave Lopper ', mail.header['From'].to_s + + # Use app_title if @author is nil or AnonymousUser + Mailer.deliver_test_email(User.find(1)) + mail = last_email + assert_equal 'redmine@example.net', mail.from_addrs.first + assert_equal "Foo ", mail.header['From'].to_s + end + end + def test_should_not_send_email_without_recipient news = News.first user = news.author -- cgit v1.2.3