This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

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