diff options
author | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-02-24 15:31:58 +0100 |
---|---|---|
committer | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-02-24 15:34:56 +0100 |
commit | 5818cf063bda5f6a96ccefe086b64a3699dd2c67 (patch) | |
tree | c46775c46c5410ef90911083c31f8a46f55e141a /spec | |
parent | aff7ac37ad27df853d42445d615f4356a91d85c8 (diff) | |
download | gitlab-ce-5818cf063bda5f6a96ccefe086b64a3699dd2c67.tar.gz |
Don't send an email for "mentioned in" notes
Currently, an email is sent every time a mentionable is referenced
by an issue, a commit or a merge request: if I comment "This MR is
related to #5", watchers get one email for the comment, and another
one stating "Issue #5 was mentioned by issue #13".
This is annoying — but the biggest issue is when pushing an existing
branch. Every issue referenced by commit messages in this branch will
get a new mention (which is fine), and dozens of emails will be sent
for all these new mentions (which is not).
This commit fixes the spam by avoiding to send an email when a new
mention is created. In most cases the email notification for the
mentioner is enough.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/notification_service_spec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index e378be04255..0869ebc9e0f 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -32,6 +32,7 @@ describe NotificationService do describe 'Notes' do context 'issue note' do let(:issue) { create(:issue, assignee: create(:user)) } + let(:mentioned_issue) { create(:issue, assignee: issue.assignee) } let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@mention referenced') } before do @@ -50,6 +51,13 @@ describe NotificationService do notification.new_note(note) end + it 'filters out "mentioned in" notes' do + mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author, issue.project) + + Notify.should_not_receive(:note_issue_email) + notification.new_note(mentioned_note) + end + def should_email(user_id) Notify.should_receive(:note_issue_email).with(user_id, note.id) end |