Commit 8208d9f8 authored by Mark Chao's avatar Mark Chao

Allows builder to include watchers for group level target

parent 914a3b24
......@@ -240,7 +240,13 @@ module NotificationRecipientService
def build!
add_participants(current_user)
if project
add_project_watchers
else # for group level targets
add_group_watchers
end
add_custom_notifications
# Re-assign is considered as a mention of the new assignee
......
......@@ -35,20 +35,41 @@ describe NewEpicWorker do
end
context 'when everything is ok' do
let(:mentioned) { create(:user) }
let(:user) { create(:user) }
let(:epic) { create(:epic, description: "epic for #{mentioned.to_reference}") }
let(:epic) { create(:epic) }
before do
stub_licensed_features(epics: true)
end
context 'user watches group' do
before do
create(
:notification_setting,
user: user,
source: epic.group,
level: NotificationSetting.levels[:watch]
)
end
it 'creates a notification for watcher' do
expect(Notify).to receive(:new_epic_email).with(user.id, epic.id, nil)
.and_return(double(deliver_later: true))
worker.perform(epic.id, user.id)
end
end
context 'mention' do
let(:epic) { create(:epic, description: "epic for #{user.to_reference}") }
it 'creates a notification for the mentioned user' do
expect(Notify).to receive(:new_epic_email).with(mentioned.id, epic.id, NotificationReason::MENTIONED)
expect(Notify).to receive(:new_epic_email).with(user.id, epic.id, NotificationReason::MENTIONED)
.and_return(double(deliver_later: true))
worker.perform(epic.id, user.id)
end
end
end
end
end
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