Commit 72d37d24 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'fj-fix-snippet-url-to-repo' into 'master'

Fix remove special chars from snippet url_to_repo

See merge request gitlab-org/gitlab!27390
parents 14d5ae82 402c0312
...@@ -283,6 +283,10 @@ class Snippet < ApplicationRecord ...@@ -283,6 +283,10 @@ class Snippet < ApplicationRecord
end end
end end
def url_to_repo
Gitlab::Shell.url_to_repo(full_path.delete('@'))
end
def repository_storage def repository_storage
snippet_repository&.shard_name || snippet_repository&.shard_name ||
Gitlab::CurrentSettings.pick_repository_storage Gitlab::CurrentSettings.pick_repository_storage
......
---
title: Fix remove special chars from snippet url_to_repo
merge_request: 27390
author:
type: fixed
...@@ -697,4 +697,20 @@ describe Snippet do ...@@ -697,4 +697,20 @@ describe Snippet do
it { is_expected.to eq result } it { is_expected.to eq result }
end end
end end
describe '#url_to_repo' do
subject { snippet.url_to_repo }
context 'with personal snippet' do
let(:snippet) { create(:personal_snippet) }
it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "snippets/#{snippet.id}.git") }
end
context 'with project snippet' do
let(:snippet) { create(:project_snippet) }
it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "#{snippet.project.full_path}/snippets/#{snippet.id}.git") }
end
end
end end
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