summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-30 13:23:16 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-30 13:23:16 +0000
commit8388bbe82918d2fca2600620f48e048ccfab2c97 (patch)
tree5d018d6f4a71dd5ab6e9e4f7b8d9ced5311ed168
parent6cb5d3d2d4c88183a79c2587d7d1bcc4797c406e (diff)
parentdade6650e1fe9ba13462957c15126d506e98673a (diff)
downloadgitlab-ce-8388bbe82918d2fca2600620f48e048ccfab2c97.tar.gz
Merge branch 'notify-on-mention-everywhere' into 'master'
Notify on mention everywhere Fixes gitlab/gitlabhq#1558 See merge request !1228
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/concerns/mentionable.rb6
-rw-r--r--app/services/notification_service.rb1
-rw-r--r--spec/models/concerns/mentionable_spec.rb14
4 files changed, 17 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f01267c460c..1d1c6d26e11 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ v 7.5.0
- Fix LDAP authentication for Git HTTP access
- Fix LDAP config lookup for provider 'ldap'
- Add Atlassian Bamboo CI service (Drew Blessing)
+ - Mentioned @user will receive email even if he is not participating in issue or commit
v 7.4.2
- Fix internal snippet exposing for unauthenticated users
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 5938d9cb28e..6c1aa99668a 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -52,11 +52,7 @@ module Mentionable
if identifier == "all"
users += project.team.members.flatten
else
- if has_project
- id = project.team.members.find_by(username: identifier).try(:id)
- else
- id = User.find_by(username: identifier).try(:id)
- end
+ id = User.find_by(username: identifier).try(:id)
users << User.find(id) unless id.blank?
end
end
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 36781314278..c9a1574b84e 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -124,6 +124,7 @@ class NotificationService
opts = { noteable_type: note.noteable_type, project_id: note.project_id }
target = note.noteable
+
if target.respond_to?(:participants)
recipients = target.participants
else
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb
new file mode 100644
index 00000000000..ca6f11b2a4d
--- /dev/null
+++ b/spec/models/concerns/mentionable_spec.rb
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe Issue, "Mentionable" do
+ describe :mentioned_users do
+ let!(:user) { create(:user, username: 'stranger') }
+ let!(:user2) { create(:user, username: 'john') }
+ let!(:issue) { create(:issue, description: '@stranger mentioned') }
+
+ subject { issue.mentioned_users }
+
+ it { should include(user) }
+ it { should_not include(user2) }
+ end
+end