summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorReuben Pereira <reuben453@gmail.com>2018-07-03 00:16:25 +0530
committerReuben Pereira <reuben453@gmail.com>2018-07-03 00:16:25 +0530
commit4fb466249fd06b87507244796286fbf56f65200a (patch)
treeb141f7c26f102b2634d4a0cd16b96a3acff266ae /spec
parentb74ed743e4e7bfb7570f3d3146ae2254a1fa8c9b (diff)
downloadgitlab-ce-4fb466249fd06b87507244796286fbf56f65200a.tar.gz
Add a spec for a user viewing a reference to a private project
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/banzai/reference_parser/project_parser_spec.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/spec/lib/banzai/reference_parser/project_parser_spec.rb b/spec/lib/banzai/reference_parser/project_parser_spec.rb
index 4a6c2294fbd..c6a4d15e47c 100644
--- a/spec/lib/banzai/reference_parser/project_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/project_parser_spec.rb
@@ -14,7 +14,7 @@ describe Banzai::ReferenceParser::ProjectParser do
it 'returns an Array of projects' do
link['data-project'] = project.id.to_s
- expect(subject.referenced_by([link])).to eq([project])
+ expect(subject.gather_references([link])).to eq([project])
end
end
@@ -22,7 +22,25 @@ describe Banzai::ReferenceParser::ProjectParser do
it 'returns an empty Array' do
link['data-project'] = ''
- expect(subject.referenced_by([link])).to eq([])
+ expect(subject.gather_references([link])).to eq([])
+ end
+ end
+
+ context 'using a private project ID' do
+ it 'returns an empty Array when unauthorized' do
+ private_project = create(:project, :private)
+
+ link['data-project'] = private_project.id.to_s
+
+ expect(subject.gather_references([link])).to eq([])
+ end
+
+ it 'returns an Array when authorized' do
+ private_project = create(:project, :private, namespace: user.namespace)
+
+ link['data-project'] = private_project.id.to_s
+
+ expect(subject.gather_references([link])).to eq([private_project])
end
end
end