Skip to content

Commit

Permalink
第17回作業分
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-nishizaki committed May 15, 2022
1 parent e833363 commit f7d9430
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def self.default_url_options
end

# Builds a mail for notifying user about a new issue
def issue_add(user, issue, recipients)
def issue_add(user, issue, recipients=nil)
redmine_headers 'Project' => issue.project.identifier,
'Issue-Tracker' => issue.tracker.name,
'Issue-Id' => issue.id,
Expand Down Expand Up @@ -102,7 +102,7 @@ def self.deliver_issue_add(issue)
end

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

# Builds a mail to user about a new document.
def document_added(user, document, author, recipients)
def document_added(user, document, author, recipients=nil)
redmine_headers 'Project' => document.project.identifier
@author = author
@document = document
Expand Down
49 changes: 49 additions & 0 deletions test/unit/mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,21 @@ def test_issue_add_should_include_issue_status_type_badge
end
end

def test_issue_add_should_include_recipients_on_mail_footer
with_settings :show_recipients_in_mail_footer => '1' do
issue = Issue.find(1)
Mailer.deliver_issue_add(issue)
mail = last_email
assert_select_email do
assert_select 'span.recipients' do |span|
assert_include 'The following recipients have also received this email.', span.text
assert_include 'John Smith', span.text
assert_include 'Dave Lopper', span.text
end
end
end
end

def test_issue_edit_subject_should_include_status_changes_if_setting_is_enabled
with_settings :show_status_changes_in_mail_subject => 1 do
issue = Issue.find(2)
Expand Down Expand Up @@ -654,6 +669,40 @@ def test_issue_edit_should_notify_mentioned_users_in_notes
assert_include User.find(1).mail, recipients
end

def test_issue_edit_should_include_recipients_on_mail_footer
with_settings :show_recipients_in_mail_footer => '1' do
issue = Issue.find(1)
issue.init_journal(User.current)
issue.update(:status_id => 4)
journal = issue.journals.last
Mailer.deliver_issue_edit(journal)
mail = last_email
assert_select_email do
assert_select 'span.recipients' do |span|
assert_include 'The following recipients have also received this email.', span.text
assert_include 'John Smith', span.text
assert_include 'Dave Lopper', span.text
end
end
end
end

def test_document_added_should_include_recipients_on_mail_footer
with_settings :show_recipients_in_mail_footer => '1' do
document = Document.find(1)
author = User.find(2)
Mailer.deliver_document_added(document, author)
mail = last_email
assert_select_email do
assert_select 'span.recipients' do |span|
assert_include 'The following recipients have also received this email.', span.text
assert_include 'John Smith', span.text
assert_include 'Dave Lopper', span.text
end
end
end
end

def test_issue_should_send_email_notification_with_suppress_empty_fields
ActionMailer::Base.deliveries.clear
with_settings :notified_events => %w(issue_added) do
Expand Down

0 comments on commit f7d9430

Please sign in to comment.