Skip to content

Commit a23b8fe

Browse files
juno-nishizakimatobaa
authored andcommitted
第17回作業分
1 parent ac8fa71 commit a23b8fe

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
@@ -517,6 +517,21 @@ def test_issue_add_should_include_issue_status_type_badge
517517
end
518518
end
519519

520+
def test_issue_add_should_include_recipients_on_mail_footer
521+
with_settings :show_recipients_in_mail_footer => '1' do
522+
issue = Issue.find(1)
523+
Mailer.deliver_issue_add(issue)
524+
mail = last_email
525+
assert_select_email do
526+
assert_select 'span.recipients' do |span|
527+
assert_include 'The following recipients have also received this email.', span.text
528+
assert_include 'John Smith', span.text
529+
assert_include 'Dave Lopper', span.text
530+
end
531+
end
532+
end
533+
end
534+
520535
def test_issue_edit_subject_should_include_status_changes_if_setting_is_enabled
521536
with_settings :show_status_changes_in_mail_subject => 1 do
522537
issue = Issue.find(2)
@@ -608,6 +623,40 @@ def test_issue_edit_with_relation_should_notify_users_who_can_see_the_related_is
608623
end
609624
end
610625

626+
def test_issue_edit_should_include_recipients_on_mail_footer
627+
with_settings :show_recipients_in_mail_footer => '1' do
628+
issue = Issue.find(1)
629+
issue.init_journal(User.current)
630+
issue.update(:status_id => 4)
631+
journal = issue.journals.last
632+
Mailer.deliver_issue_edit(journal)
633+
mail = last_email
634+
assert_select_email do
635+
assert_select 'span.recipients' do |span|
636+
assert_include 'The following recipients have also received this email.', span.text
637+
assert_include 'John Smith', span.text
638+
assert_include 'Dave Lopper', span.text
639+
end
640+
end
641+
end
642+
end
643+
644+
def test_document_added_should_include_recipients_on_mail_footer
645+
with_settings :show_recipients_in_mail_footer => '1' do
646+
document = Document.find(1)
647+
author = User.find(2)
648+
Mailer.deliver_document_added(document, author)
649+
mail = last_email
650+
assert_select_email do
651+
assert_select 'span.recipients' do |span|
652+
assert_include 'The following recipients have also received this email.', span.text
653+
assert_include 'John Smith', span.text
654+
assert_include 'Dave Lopper', span.text
655+
end
656+
end
657+
end
658+
end
659+
611660
def test_issue_should_send_email_notification_with_suppress_empty_fields
612661
ActionMailer::Base.deliveries.clear
613662
with_settings :notified_events => %w(issue_added) do

0 commit comments

Comments
 (0)