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