Skip to content

Commit 1faa1c8

Browse files
juno-nishizakiRedmine Patch Meetup
authored andcommitted
第17回作業分
1 parent 21e12d0 commit 1faa1c8

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

app/models/mailer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def self.default_url_options
7070
end
7171

7272
# Builds a mail for notifying user about a new issue
73-
def issue_add(user, issue, recipients)
73+
def issue_add(user, issue, recipients=nil)
7474
redmine_headers 'Project' => issue.project.identifier,
7575
'Issue-Tracker' => issue.tracker.name,
7676
'Issue-Id' => issue.id,
@@ -103,7 +103,7 @@ def self.deliver_issue_add(issue)
103103
end
104104

105105
# Builds a mail for notifying user about an issue update
106-
def issue_edit(user, journal, recipients)
106+
def issue_edit(user, journal, recipients=nil)
107107
issue = journal.journalized
108108
redmine_headers 'Project' => issue.project.identifier,
109109
'Issue-Tracker' => issue.tracker.name,
@@ -143,7 +143,7 @@ def self.deliver_issue_edit(journal)
143143
end
144144

145145
# Builds a mail to user about a new document.
146-
def document_added(user, document, author, recipients)
146+
def document_added(user, document, author, recipients=nil)
147147
redmine_headers 'Project' => document.project.identifier
148148
@author = author
149149
@document = document

test/unit/mailer_test.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,21 @@ def test_issue_add_should_include_issue_status_type_badge
531531
end
532532
end
533533

534+
def test_issue_add_should_include_recipients_on_mail_footer
535+
with_settings :show_recipients_in_mail_footer => '1' do
536+
issue = Issue.find(1)
537+
Mailer.deliver_issue_add(issue)
538+
mail = last_email
539+
assert_select_email do
540+
assert_select 'span.recipients' do |span|
541+
assert_include 'The following recipients have also received this email.', span.text
542+
assert_include 'John Smith', span.text
543+
assert_include 'Dave Lopper', span.text
544+
end
545+
end
546+
end
547+
end
548+
534549
def test_issue_edit_subject_should_include_status_changes_if_setting_is_enabled
535550
with_settings :show_status_changes_in_mail_subject => 1 do
536551
issue = Issue.find(2)
@@ -655,6 +670,40 @@ def test_issue_edit_should_notify_mentioned_users_in_notes
655670
assert_include User.find(1).mail, recipients
656671
end
657672

673+
def test_issue_edit_should_include_recipients_on_mail_footer
674+
with_settings :show_recipients_in_mail_footer => '1' do
675+
issue = Issue.find(1)
676+
issue.init_journal(User.current)
677+
issue.update(:status_id => 4)
678+
journal = issue.journals.last
679+
Mailer.deliver_issue_edit(journal)
680+
mail = last_email
681+
assert_select_email do
682+
assert_select 'span.recipients' do |span|
683+
assert_include 'The following recipients have also received this email.', span.text
684+
assert_include 'John Smith', span.text
685+
assert_include 'Dave Lopper', span.text
686+
end
687+
end
688+
end
689+
end
690+
691+
def test_document_added_should_include_recipients_on_mail_footer
692+
with_settings :show_recipients_in_mail_footer => '1' do
693+
document = Document.find(1)
694+
author = User.find(2)
695+
Mailer.deliver_document_added(document, author)
696+
mail = last_email
697+
assert_select_email do
698+
assert_select 'span.recipients' do |span|
699+
assert_include 'The following recipients have also received this email.', span.text
700+
assert_include 'John Smith', span.text
701+
assert_include 'Dave Lopper', span.text
702+
end
703+
end
704+
end
705+
end
706+
658707
def test_issue_should_send_email_notification_with_suppress_empty_fields
659708
ActionMailer::Base.deliveries.clear
660709
with_settings :notified_events => %w(issue_added) do

0 commit comments

Comments
 (0)