summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-02-15 23:52:30 +0000
committerGo MAEDA <maeda@farend.jp>2019-02-15 23:52:30 +0000
commit21e503fc7100049131c41d27a33ec62094135263 (patch)
tree2eddf9283f1287490db8401e4c6fcceb37496d85 /test/unit
parent6a639cdf0fd331c17c63a0e777dea64239e4eb3c (diff)
downloadredmine-21e503fc7100049131c41d27a33ec62094135263.tar.gz
redmine-21e503fc7100049131c41d27a33ec62094135263.zip
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
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/mailer_test.rb19
1 files changed, 19 insertions, 0 deletions
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 <redmine@example.net>', 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 <redmine@example.net>', 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 <redmine@example.net>", mail.header['From'].to_s
+ end
+ end
+
def test_should_not_send_email_without_recipient
news = News.first
user = news.author