summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2016-05-07 01:31:56 +0200
committerAhmad Sherif <me@ahmadsherif.com>2016-05-07 01:37:29 +0200
commitab4671f26ab789b1e3647754911197aaba1f81bb (patch)
tree686244985b9e178a5d59dd7cf202d75fc7e55cc9
parent2e1162272e2f90a3677f3def491907729b249434 (diff)
downloadgitlab-ce-ab4671f26ab789b1e3647754911197aaba1f81bb.tar.gz
Fix adding a todo for private group members
Fixes #14002
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/concerns/mentionable.rb4
-rw-r--r--spec/services/todo_service_spec.rb19
3 files changed, 22 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 78d6c1ec2b2..c68a11a91f6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,7 @@ v 8.8.0 (unreleased)
- Fix Gravatar hint in user profile when Gravatar is disabled. !3988 (Artem Sidorenko)
- Expire repository exists? and has_visible_content? caches after a push if necessary
- Fix unintentional filtering bug in issues sorted by milestone due (Takuya Noguchi)
+ - Fix adding a todo for private group members (Ahmad Sherif)
v 8.7.3
- Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 98f71ae8cb0..b381d225485 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -43,8 +43,8 @@ module Mentionable
self
end
- def all_references(current_user = self.author, text = nil)
- ext = Gitlab::ReferenceExtractor.new(self.project, current_user, self.author)
+ def all_references(current_user = nil, text = nil)
+ ext = Gitlab::ReferenceExtractor.new(self.project, current_user || self.author, self.author)
if text
ext.analyze(text)
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 82b7fbfa816..a075496ee63 100644
--- a/spec/services/todo_service_spec.rb
+++ b/spec/services/todo_service_spec.rb
@@ -55,6 +55,25 @@ describe TodoService, services: true do
should_create_todo(user: admin, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
should_not_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
end
+
+ context 'when a private group is mentioned' do
+ let(:group) { create :group, :private }
+ let(:project) { create :project, :private, group: group }
+ let(:issue) { create :issue, author: author, project: project, description: group.to_reference }
+
+ before do
+ group.add_owner(author)
+ group.add_user(member, Gitlab::Access::DEVELOPER)
+ group.add_user(john_doe, Gitlab::Access::DEVELOPER)
+
+ service.new_issue(issue, author)
+ end
+
+ it 'creates a todo for group members' do
+ should_create_todo(user: member, target: issue)
+ should_create_todo(user: john_doe, target: issue)
+ end
+ end
end
describe '#update_issue' do