summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarzyna Kobierska <kkobierska@gmail.com>2016-09-30 14:53:37 +0200
committerKatarzyna Kobierska <kkobierska@gmail.com>2016-10-03 12:05:55 +0200
commitbf3b8d1c1d3d854311a638ebeaf87991367e4052 (patch)
tree74ea5d441a0803d7946d5f57b05bc749e142e5b6
parentf5e43f0788438758e4b1404da19fb4255245aead (diff)
downloadgitlab-ce-bf3b8d1c1d3d854311a638ebeaf87991367e4052.tar.gz
Fix test, add author attribute to all tests
-rw-r--r--CHANGELOG1
-rw-r--r--lib/banzai/filter/user_reference_filter.rb4
-rw-r--r--spec/lib/banzai/filter/user_reference_filter_spec.rb9
3 files changed, 12 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a52ac53bae7..b55ac5eb511 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,7 @@ v 8.13.0 (unreleased)
- Optimize GitHub importing for speed and memory
- API: expose pipeline data in builds API (!6502, Guilherme Salazar)
- Notify the Merger about merge after successful build (Dimitris Karakasilis)
+ - Prevent rendering the link to all when the author has no access (Katarzyna Kobierska Ula Budziszewska)
- Fix broken repository 500 errors in project list
- Close todos when accepting merge requests via the API !6486 (tonygambone)
diff --git a/lib/banzai/filter/user_reference_filter.rb b/lib/banzai/filter/user_reference_filter.rb
index b3c8e565c27..c6302b586d3 100644
--- a/lib/banzai/filter/user_reference_filter.rb
+++ b/lib/banzai/filter/user_reference_filter.rb
@@ -106,8 +106,8 @@ module Banzai
project = context[:project]
author = context[:author]
- if author && !project.team.member?(author)
- '@all'
+ if author && !project.team.member?(author)
+ link_text
else
url = urls.namespace_project_url(project.namespace, project,
only_path: context[:only_path])
diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb
index fdbdb21eac1..4b1ea6403cc 100644
--- a/spec/lib/banzai/filter/user_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb
@@ -31,13 +31,16 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do
end
it 'supports a special @all mention' do
+ project.team << [user, :developer]
doc = reference_filter("Hey #{reference}", author: user)
+
expect(doc.css('a').length).to eq 1
expect(doc.css('a').first.attr('href'))
.to eq urls.namespace_project_url(project.namespace, project)
end
it 'includes a data-author attribute when there is an author' do
+ project.team << [user, :developer]
doc = reference_filter(reference, author: user)
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
expect(doc.css('a').first.has_attribute?('data-author')).to eq(false)
end
+
+ it 'ignores reference to all when user is not a project member' do
+ doc = reference_filter("Hey #{reference}", author: user)
+
+ expect(doc.css('a').length).to eq 0
+ end
end
context 'mentioning a user' do