Commit ddb23d3b authored by Sean McGivern's avatar Sean McGivern

Send issue due emails to all participants

parent f4c8517f
...@@ -230,7 +230,7 @@ module NotificationRecipientService ...@@ -230,7 +230,7 @@ module NotificationRecipientService
add_subscribed_users add_subscribed_users
if [:new_issue, :new_merge_request, :due_date_issue].include?(custom_action) if [:new_issue, :new_merge_request].include?(custom_action)
# These will all be participants as well, but adding with the :mention # These will all be participants as well, but adding with the :mention
# type ensures that users with the mention notification level will # type ensures that users with the mention notification level will
# receive them, too. # receive them, too.
...@@ -238,7 +238,7 @@ module NotificationRecipientService ...@@ -238,7 +238,7 @@ module NotificationRecipientService
# Add the assigned users, if any # Add the assigned users, if any
assignees = case custom_action assignees = case custom_action
when :new_issue, :due_date_issue when :new_issue
target.assignees target.assignees
else else
target.assignee target.assignee
......
...@@ -363,7 +363,7 @@ class NotificationService ...@@ -363,7 +363,7 @@ class NotificationService
end end
end end
def issue_due_email(issue) def issue_due(issue)
recipients = NotificationRecipientService.build_recipients( recipients = NotificationRecipientService.build_recipients(
issue, issue,
issue.author, issue.author,
......
require 'spec_helper'
describe NotificationRecipientService do
describe 'build_recipients' do
it 'due_date' do
# These folks are being filtered out because they can't receive notifications
# notification_recipient.rb#85
user = create(:user)
assignee = create(:user)
issue = create(:issue, :opened, due_date: Date.today, author: user, assignees: [assignee])
recipients = described_class.build_recipients(
issue,
issue.author,
action: "due_date",
skip_current_user: false
)
expect(recipients).to match_array([user, assignee])
end
end
end
...@@ -933,6 +933,37 @@ describe NotificationService, :mailer do ...@@ -933,6 +933,37 @@ describe NotificationService, :mailer do
let(:notification_trigger) { notification.issue_moved(issue, new_issue, @u_disabled) } let(:notification_trigger) { notification.issue_moved(issue, new_issue, @u_disabled) }
end end
end end
describe '#issue_due' do
it 'sends email to issue notification recipients' do
notification.issue_due(issue)
should_email(issue.assignees.first)
should_email(issue.author)
should_email(@u_watcher)
should_email(@u_guest_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_email(@watcher_and_subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
should_not_email(@u_lazy_participant)
end
it 'sends the email from the author' do
notification.issue_due(issue)
email = find_email_for(@subscriber)
expect(email.header[:from].display_names).to eq([issue.author.name])
end
it_behaves_like 'participating notifications' do
let(:participant) { create(:user, username: 'user-participant') }
let(:issuable) { issue }
let(:notification_trigger) { notification.issue_due(issue) }
end
end
end end
describe 'Merge Requests' do describe 'Merge Requests' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment