Mentioned users are not limited by project scope any more

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-10-29 15:46:42 +02:00
parent 408bbb1bc6
commit fd17ba9ffc
3 changed files with 16 additions and 5 deletions

View file

@ -51,12 +51,8 @@ module Mentionable
identifier = match.delete "@" identifier = match.delete "@"
if identifier == "all" if identifier == "all"
users += project.team.members.flatten users += project.team.members.flatten
else
if has_project
id = project.team.members.find_by(username: identifier).try(:id)
else else
id = User.find_by(username: identifier).try(:id) id = User.find_by(username: identifier).try(:id)
end
users << User.find(id) unless id.blank? users << User.find(id) unless id.blank?
end end
end end

View file

@ -124,6 +124,7 @@ class NotificationService
opts = { noteable_type: note.noteable_type, project_id: note.project_id } opts = { noteable_type: note.noteable_type, project_id: note.project_id }
target = note.noteable target = note.noteable
if target.respond_to?(:participants) if target.respond_to?(:participants)
recipients = target.participants recipients = target.participants
else else

View file

@ -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