Skip to content

Commit 77235a1

Browse files
juno-nishizakiRedmine Patch Meetup
authored andcommitted
第17回作業分
1 parent e4b3dcd commit 77235a1

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,
@@ -102,7 +102,7 @@ def self.deliver_issue_add(issue)
102102
end
103103

104104
# Builds a mail for notifying user about an issue update
105-
def issue_edit(user, journal, recipients)
105+
def issue_edit(user, journal, recipients=nil)
106106
issue = journal.journalized
107107
redmine_headers 'Project' => issue.project.identifier,
108108
'Issue-Tracker' => issue.tracker.name,
@@ -141,7 +141,7 @@ def self.deliver_issue_edit(journal)
141141
end
142142

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

test/unit/mailer_test.rb

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

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

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

0 commit comments

Comments
 (0)