Add notification to the former assignee upon unassignment
This commit is contained in:
parent
62769e2050
commit
798873ca75
3 changed files with 11 additions and 6 deletions
|
@ -26,6 +26,7 @@ v 8.2.0 (unreleased)
|
||||||
- Add "added", "modified" and "removed" properties to commit object in webhook
|
- Add "added", "modified" and "removed" properties to commit object in webhook
|
||||||
- Rename "Back to" links to "Go to" because its not always a case it point to place user come from
|
- Rename "Back to" links to "Go to" because its not always a case it point to place user come from
|
||||||
- Allow groups to appear in the search results if the group owner allows it
|
- Allow groups to appear in the search results if the group owner allows it
|
||||||
|
- Add email notification to former assignee upon unassignment
|
||||||
|
|
||||||
v 8.1.3
|
v 8.1.3
|
||||||
- Spread out runner contacted_at updates
|
- Spread out runner contacted_at updates
|
||||||
|
|
|
@ -362,7 +362,8 @@ class NotificationService
|
||||||
|
|
||||||
def reassign_resource_email(target, project, current_user, method)
|
def reassign_resource_email(target, project, current_user, method)
|
||||||
assignee_id_was = previous_record(target, "assignee_id")
|
assignee_id_was = previous_record(target, "assignee_id")
|
||||||
recipients = build_recipients(target, project, current_user)
|
previous_assignee = User.find(assignee_id_was)
|
||||||
|
recipients = build_recipients(target, project, current_user, [previous_assignee])
|
||||||
|
|
||||||
recipients.each do |recipient|
|
recipients.each do |recipient|
|
||||||
mailer.send(method, recipient.id, target.id, assignee_id_was, current_user.id)
|
mailer.send(method, recipient.id, target.id, assignee_id_was, current_user.id)
|
||||||
|
@ -377,8 +378,9 @@ class NotificationService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_recipients(target, project, current_user)
|
def build_recipients(target, project, current_user, previous_records = nil )
|
||||||
recipients = target.participants(current_user)
|
recipients = target.participants(current_user)
|
||||||
|
recipients.concat(previous_records).compact.uniq if previous_records
|
||||||
|
|
||||||
recipients = add_project_watchers(recipients, project)
|
recipients = add_project_watchers(recipients, project)
|
||||||
recipients = reject_mention_users(recipients, project)
|
recipients = reject_mention_users(recipients, project)
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||||
describe Issues::UpdateService do
|
describe Issues::UpdateService do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:user2) { create(:user) }
|
let(:user2) { create(:user) }
|
||||||
let(:issue) { create(:issue, title: 'Old title') }
|
let(:issue) { create(:issue, title: 'Old title', assignee_id: user.id) }
|
||||||
let(:label) { create(:label) }
|
let(:label) { create(:label) }
|
||||||
let(:project) { issue.project }
|
let(:project) { issue.project }
|
||||||
|
|
||||||
|
@ -34,9 +34,11 @@ describe Issues::UpdateService do
|
||||||
it { expect(@issue.labels.count).to eq(1) }
|
it { expect(@issue.labels.count).to eq(1) }
|
||||||
it { expect(@issue.labels.first.title).to eq('Bug') }
|
it { expect(@issue.labels.first.title).to eq('Bug') }
|
||||||
|
|
||||||
it 'should send email to user2 about assign of new issue' do
|
it 'should send email to user2 about assign of new issue and email to user about issue unassignment' do
|
||||||
email = ActionMailer::Base.deliveries.last
|
deliveries = ActionMailer::Base.deliveries
|
||||||
expect(email.to.first).to eq(user2.email)
|
email = deliveries.last
|
||||||
|
recipients = deliveries.map(&:to).uniq.flatten
|
||||||
|
expect(recipients.last(2)).to include(user.email,user2.email)
|
||||||
expect(email.subject).to include(issue.title)
|
expect(email.subject).to include(issue.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue