Commit 6d5447b7 authored by Reuben Pereira's avatar Reuben Pereira
Browse files

Add back the Project#to_reference_with_postfix function since it can be used...

Add back the Project#to_reference_with_postfix function since it can be used in the ProjectReferenceFilter#link_to_project function
parent aaa211eace4e
......@@ -902,6 +902,10 @@ def to_param
end
end
def to_reference_with_postfix
"#{to_reference(full: true)}#{self.class.reference_postfix}"
end
# `from` argument can be a Namespace or Project.
def to_reference(from = nil, full: false)
if full || cross_namespace_reference?(from)
......
......@@ -102,7 +102,7 @@ def link_class
def link_to_project(project, link_content: nil)
url = urls.project_url(project, only_path: context[:only_path])
data = data_attribute(project: project.id)
content = link_content || project.full_path + Project.reference_postfix
content = link_content || project.to_reference_with_postfix
link_tag(url, data, content, project.name)
end
......
......@@ -8,7 +8,7 @@ def invalidate_reference(reference)
end
def get_reference(project)
"#{project.to_reference(full: true)}#{Project.reference_postfix}"
project.to_reference_with_postfix
end
let(:project) { create(:project, :public) }
......
......@@ -344,6 +344,15 @@
it { is_expected.to delegate_method(:name).to(:owner).with_prefix(true).with_arguments(allow_nil: true) }
end
describe '#to_reference_with_postfix' do
it 'returns the full path with reference_postfix' do
namespace = create(:namespace, path: 'sample-namespace')
project = create(:project, path: 'sample-project', namespace: namespace)
expect(project.to_reference_with_postfix).to eq 'sample-namespace/sample-project>'
end
end
describe '#to_reference' do
let(:owner) { create(:user, name: 'Gitlab') }
let(:namespace) { create(:namespace, path: 'sample-namespace', owner: owner) }
......
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