Commit c36544de authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'kradydal/gitlab-ce-20989-disable-all-for-non-project-members'

See !6474.
parents c9bb0837 fd8c30d1
...@@ -50,6 +50,7 @@ v 8.13.0 (unreleased) ...@@ -50,6 +50,7 @@ v 8.13.0 (unreleased)
- API: expose pipeline data in builds API (!6502, Guilherme Salazar) - API: expose pipeline data in builds API (!6502, Guilherme Salazar)
- Notify the Merger about merge after successful build (Dimitris Karakasilis) - Notify the Merger about merge after successful build (Dimitris Karakasilis)
- Reduce queries needed to find users using their SSH keys when pushing commits - Reduce queries needed to find users using their SSH keys when pushing commits
- Prevent rendering the link to all when the author has no access (Katarzyna Kobierska Ula Budziszewska)
- Fix broken repository 500 errors in project list - Fix broken repository 500 errors in project list
- Fix Pipeline list commit column width should be adjusted - Fix Pipeline list commit column width should be adjusted
- Close todos when accepting merge requests via the API !6486 (tonygambone) - Close todos when accepting merge requests via the API !6486 (tonygambone)
......
...@@ -106,13 +106,17 @@ module Banzai ...@@ -106,13 +106,17 @@ module Banzai
project = context[:project] project = context[:project]
author = context[:author] author = context[:author]
url = urls.namespace_project_url(project.namespace, project, if author && !project.team.member?(author)
only_path: context[:only_path]) link_text
else
url = urls.namespace_project_url(project.namespace, project,
only_path: context[:only_path])
data = data_attribute(project: project.id, author: author.try(:id)) data = data_attribute(project: project.id, author: author.try(:id))
text = link_text || User.reference_prefix + 'all' text = link_text || User.reference_prefix + 'all'
link_tag(url, data, text, 'All Project and Group Members') link_tag(url, data, text, 'All Project and Group Members')
end
end end
def link_to_namespace(namespace, link_text: nil) def link_to_namespace(namespace, link_text: nil)
......
...@@ -31,13 +31,16 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do ...@@ -31,13 +31,16 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
end end
it 'supports a special @all mention' do it 'supports a special @all mention' do
project.team << [user, :developer]
doc = reference_filter("Hey #{reference}", author: user) doc = reference_filter("Hey #{reference}", author: user)
expect(doc.css('a').length).to eq 1 expect(doc.css('a').length).to eq 1
expect(doc.css('a').first.attr('href')) expect(doc.css('a').first.attr('href'))
.to eq urls.namespace_project_url(project.namespace, project) .to eq urls.namespace_project_url(project.namespace, project)
end end
it 'includes a data-author attribute when there is an author' do it 'includes a data-author attribute when there is an author' do
project.team << [user, :developer]
doc = reference_filter(reference, author: user) doc = reference_filter(reference, author: user)
expect(doc.css('a').first.attr('data-author')).to eq(user.id.to_s) expect(doc.css('a').first.attr('data-author')).to eq(user.id.to_s)
...@@ -48,6 +51,12 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do ...@@ -48,6 +51,12 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
expect(doc.css('a').first.has_attribute?('data-author')).to eq(false) expect(doc.css('a').first.has_attribute?('data-author')).to eq(false)
end end
it 'ignores reference to all when the user is not a project member' do
doc = reference_filter("Hey #{reference}", author: user)
expect(doc.css('a').length).to eq 0
end
end end
context 'mentioning a user' do context 'mentioning a user' do
......
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