Commit 1fac8bf7 authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch 'dz-scope-repository-routes-2' into 'master'

Make repository routes under /-/ scope as default one

See merge request gitlab-org/gitlab!23391
parents e27d351b fadd7146
...@@ -35,6 +35,7 @@ export default { ...@@ -35,6 +35,7 @@ export default {
joinPaths( joinPaths(
gon.relative_url_root || '/', gon.relative_url_root || '/',
file.projectId, file.projectId,
'-',
'raw', 'raw',
sha, sha,
escapeFileUrl(filePath), escapeFileUrl(filePath),
...@@ -67,7 +68,7 @@ export default { ...@@ -67,7 +68,7 @@ export default {
return Api.commitMultiple(projectId, payload); return Api.commitMultiple(projectId, payload);
}, },
getFiles(projectUrl, ref) { getFiles(projectUrl, ref) {
const url = `${projectUrl}/files/${ref}`; const url = `${projectUrl}/-/files/${ref}`;
return axios.get(url, { params: { format: 'json' } }); return axios.get(url, { params: { format: 'json' } });
}, },
lastCommitPipelines({ getters }) { lastCommitPipelines({ getters }) {
......
...@@ -107,10 +107,10 @@ export default { ...@@ -107,10 +107,10 @@ export default {
return acc.concat({ return acc.concat({
name, name,
path, path,
to: `/tree/${this.ref}${path}`, to: `/-/tree/${this.ref}${path}`,
}); });
}, },
[{ name: this.projectShortPath, path: '/', to: `/tree/${this.ref}/` }], [{ name: this.projectShortPath, path: '/', to: `/-/tree/${this.ref}/` }],
); );
}, },
canCreateMrFromFork() { canCreateMrFromFork() {
......
...@@ -28,7 +28,7 @@ export default { ...@@ -28,7 +28,7 @@ export default {
return splitArray.join('/'); return splitArray.join('/');
}, },
parentRoute() { parentRoute() {
return { path: `/tree/${this.commitRef}/${this.parentPath}` }; return { path: `/-/tree/${this.commitRef}/${this.parentPath}` };
}, },
}, },
methods: { methods: {
......
...@@ -90,7 +90,7 @@ export default { ...@@ -90,7 +90,7 @@ export default {
}, },
computed: { computed: {
routerLinkTo() { routerLinkTo() {
return this.isFolder ? { path: `/tree/${this.ref}/${this.path}` } : null; return this.isFolder ? { path: `/-/tree/${this.ref}/${this.path}` } : null;
}, },
iconName() { iconName() {
return `fa-${getIconName(this.type, this.path)}`; return `fa-${getIconName(this.type, this.path)}`;
......
...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) { ...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) {
base: joinPaths(gon.relative_url_root || '', base), base: joinPaths(gon.relative_url_root || '', base),
routes: [ routes: [
{ {
path: `/tree/${baseRef}(/.*)?`, path: `/-/tree/${baseRef}(/.*)?`,
name: 'treePath', name: 'treePath',
component: TreePage, component: TreePage,
props: route => ({ props: route => ({
......
...@@ -79,10 +79,10 @@ export default { ...@@ -79,10 +79,10 @@ export default {
return this.projectPath.indexOf('/') === 0 ? '' : `${gon.relative_url_root}/`; return this.projectPath.indexOf('/') === 0 ? '' : `${gon.relative_url_root}/`;
}, },
fullOldPath() { fullOldPath() {
return `${this.basePath}${this.projectPath}/raw/${this.oldSha}/${this.oldPath}`; return `${this.basePath}${this.projectPath}/-/raw/${this.oldSha}/${this.oldPath}`;
}, },
fullNewPath() { fullNewPath() {
return `${this.basePath}${this.projectPath}/raw/${this.newSha}/${this.newPath}`; return `${this.basePath}${this.projectPath}/-/raw/${this.newSha}/${this.newPath}`;
}, },
}, },
}; };
......
...@@ -39,9 +39,9 @@ module SubmoduleHelper ...@@ -39,9 +39,9 @@ module SubmoduleHelper
elsif relative_self_url?(url) elsif relative_self_url?(url)
relative_self_links(url, submodule_item_id, repository.project) relative_self_links(url, submodule_item_id, repository.project)
elsif github_dot_com_url?(url) elsif github_dot_com_url?(url)
standard_links('github.com', namespace, project, submodule_item_id) github_com_tree_links(namespace, project, submodule_item_id)
elsif gitlab_dot_com_url?(url) elsif gitlab_dot_com_url?(url)
standard_links('gitlab.com', namespace, project, submodule_item_id) gitlab_com_tree_links(namespace, project, submodule_item_id)
else else
[sanitize_submodule_url(url), nil] [sanitize_submodule_url(url), nil]
end end
...@@ -73,8 +73,13 @@ module SubmoduleHelper ...@@ -73,8 +73,13 @@ module SubmoduleHelper
url.start_with?('../', './') url.start_with?('../', './')
end end
def standard_links(host, namespace, project, commit) def gitlab_com_tree_links(namespace, project, commit)
base = ['https://', host, '/', namespace, '/', project].join('') base = ['https://gitlab.com/', namespace, '/', project].join('')
[base, [base, '/-/tree/', commit].join('')]
end
def github_com_tree_links(namespace, project, commit)
base = ['https://github.com/', namespace, '/', project].join('')
[base, [base, '/tree/', commit].join('')] [base, [base, '/tree/', commit].join('')]
end end
......
...@@ -38,13 +38,13 @@ module TreeHelper ...@@ -38,13 +38,13 @@ module TreeHelper
# many paths, as with a repository tree that has thousands of items. # many paths, as with a repository tree that has thousands of items.
def fast_project_blob_path(project, blob_path) def fast_project_blob_path(project, blob_path)
ActionDispatch::Journey::Router::Utils.escape_path( ActionDispatch::Journey::Router::Utils.escape_path(
File.join(relative_url_root, project.path_with_namespace, 'blob', blob_path) File.join(relative_url_root, project.path_with_namespace, '-', 'blob', blob_path)
) )
end end
def fast_project_tree_path(project, tree_path) def fast_project_tree_path(project, tree_path)
ActionDispatch::Journey::Router::Utils.escape_path( ActionDispatch::Journey::Router::Utils.escape_path(
File.join(relative_url_root, project.path_with_namespace, 'tree', tree_path) File.join(relative_url_root, project.path_with_namespace, '-', 'tree', tree_path)
) )
end end
......
---
title: Move repository routes under - scope
merge_request: 20455
author:
type: deprecated
...@@ -286,6 +286,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -286,6 +286,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# The wiki and repository routing contains wildcard characters so # The wiki and repository routing contains wildcard characters so
# its preferable to keep it below all other project routes # its preferable to keep it below all other project routes
draw :repository_scoped draw :repository_scoped
draw :repository
draw :wiki draw :wiki
end end
# End of the /-/ scope. # End of the /-/ scope.
...@@ -476,14 +477,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -476,14 +477,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :web_ide_clientside_preview post :web_ide_clientside_preview
end end
# The repository routing contains wildcard characters so # Deprecated unscoped routing.
# its preferable to keep it below all other project routes
draw :repository
# To ensure an old unscoped routing is used for the UI we need to
# add prefix 'as' to the scope routing and place it below original routing.
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
scope '-', as: 'scoped' do scope as: 'deprecated' do
draw :repository draw :repository
end end
......
...@@ -36,7 +36,7 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -36,7 +36,7 @@ const GUIDED_GITLAB_TOUR = [
}, },
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/tree/master$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/tree/master$`, ''),
getHelpContent: ({ projectName }) => [ getHelpContent: ({ projectName }) => [
{ {
text: sprintf( text: sprintf(
...@@ -69,7 +69,7 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -69,7 +69,7 @@ const GUIDED_GITLAB_TOUR = [
}, },
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commits/master$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/commits/master$`, ''),
getHelpContent: () => [ getHelpContent: () => [
{ {
text: s__( text: s__(
......
...@@ -211,7 +211,7 @@ scope path: '(/-/jira)', constraints: ::Constraints::JiraEncodedUrlConstrainer.n ...@@ -211,7 +211,7 @@ scope path: '(/-/jira)', constraints: ::Constraints::JiraEncodedUrlConstrainer.n
project: params[:project_id] project: params[:project_id]
) )
"/#{project_full_path}/tree/#{params[:id]}" "/#{project_full_path}/-/tree/#{params[:id]}"
} }
end end
end end
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"deployed_at": "2019-02-20T16:15:40.122Z", "deployed_at": "2019-02-20T16:15:40.122Z",
"ref": { "ref": {
"name": "master", "name": "master",
"ref_path": "/root/minimal-ruby-app/tree/master", "ref_path": "/root/minimal-ruby-app/-/tree/master",
"tag": false "tag": false
}, },
"created_at": "2019-02-20T16:09:12.213Z", "created_at": "2019-02-20T16:09:12.213Z",
......
...@@ -12,7 +12,7 @@ describe EE::VersionCheckHelper do ...@@ -12,7 +12,7 @@ describe EE::VersionCheckHelper do
end end
it 'links to an ee-commit' do it 'links to an ee-commit' do
expect(helper.link_to_version).to include('https://gitlab.com/gitlab-org/gitlab/commits/deadbeef') expect(helper.link_to_version).to include('https://gitlab.com/gitlab-org/gitlab/-/commits/deadbeef')
end end
end end
......
...@@ -19,7 +19,7 @@ describe Gitlab::Ci::Parsers::Security::DependencyList do ...@@ -19,7 +19,7 @@ describe Gitlab::Ci::Parsers::Security::DependencyList do
let(:artifact) { create(:ee_ci_job_artifact, :dependency_list) } let(:artifact) { create(:ee_ci_job_artifact, :dependency_list) }
it 'parses all files' do it 'parses all files' do
blob_path = "/#{project.full_path}/blob/#{sha}/yarn/yarn.lock" blob_path = "/#{project.full_path}/-/blob/#{sha}/yarn/yarn.lock"
expect(report.dependencies.size).to eq(21) expect(report.dependencies.size).to eq(21)
expect(report.dependencies[0][:name]).to eq('mini_portile2') expect(report.dependencies[0][:name]).to eq('mini_portile2')
......
...@@ -20,7 +20,7 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DependencyList do ...@@ -20,7 +20,7 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DependencyList do
let(:package_manager) { 'bundler' } let(:package_manager) { 'bundler' }
let(:file_path) { 'rails/Gemfile.lock' } let(:file_path) { 'rails/Gemfile.lock' }
let(:data) { formatter.format(dependency, package_manager, file_path, parsed_report['vulnerabilities']) } let(:data) { formatter.format(dependency, package_manager, file_path, parsed_report['vulnerabilities']) }
let(:blob_path) { "/#{project.full_path}/blob/#{sha}/rails/Gemfile.lock" } let(:blob_path) { "/#{project.full_path}/-/blob/#{sha}/rails/Gemfile.lock" }
context 'with secure dependency' do context 'with secure dependency' do
let(:dependency) { parsed_report['dependency_files'][0]['dependencies'][0] } let(:dependency) { parsed_report['dependency_files'][0]['dependencies'][0] }
......
...@@ -265,7 +265,7 @@ describe Ci::Build do ...@@ -265,7 +265,7 @@ describe Ci::Build do
it 'parses blobs and add the results to the report' do it 'parses blobs and add the results to the report' do
subject subject
blob_path = "/#{project.full_path}/blob/#{job.sha}/yarn/yarn.lock" blob_path = "/#{project.full_path}/-/blob/#{job.sha}/yarn/yarn.lock"
mini_portile2 = dependency_list_report.dependencies[0] mini_portile2 = dependency_list_report.dependencies[0]
yarn = dependency_list_report.dependencies[20] yarn = dependency_list_report.dependencies[20]
......
...@@ -30,7 +30,7 @@ describe 'Jira referenced paths', type: :request do ...@@ -30,7 +30,7 @@ describe 'Jira referenced paths', type: :request do
'/group/group@sub_group@sub_group_project' | '/group/sub_group/sub_group_project' '/group/group@sub_group@sub_group_project' | '/group/sub_group/sub_group_project'
'/group@sub_group/group@sub_group@sub_group_project' | '/group/sub_group/sub_group_project' '/group@sub_group/group@sub_group@sub_group_project' | '/group/sub_group/sub_group_project'
'/group/group@sub_group@sub_group_project/commit/1234567' | '/group/sub_group/sub_group_project/commit/1234567' '/group/group@sub_group@sub_group_project/commit/1234567' | '/group/sub_group/sub_group_project/commit/1234567'
'/group/group@sub_group@sub_group_project/tree/1234567' | '/group/sub_group/sub_group_project/tree/1234567' '/group/group@sub_group@sub_group_project/tree/1234567' | '/group/sub_group/sub_group_project/-/tree/1234567'
end end
with_them do with_them do
...@@ -50,7 +50,7 @@ describe 'Jira referenced paths', type: :request do ...@@ -50,7 +50,7 @@ describe 'Jira referenced paths', type: :request do
where(:jira_path, :redirect_path) do where(:jira_path, :redirect_path) do
'/-/jira/group/group_project' | '/group/group_project' '/-/jira/group/group_project' | '/group/group_project'
'/-/jira/group/group_project/commit/1234567' | '/group/group_project/commit/1234567' '/-/jira/group/group_project/commit/1234567' | '/group/group_project/commit/1234567'
'/-/jira/group/group_project/tree/1234567' | '/group/group_project/tree/1234567' '/-/jira/group/group_project/tree/1234567' | '/group/group_project/-/tree/1234567'
end end
with_them do with_them do
......
...@@ -101,11 +101,18 @@ module Banzai ...@@ -101,11 +101,18 @@ module Banzai
def rebuild_relative_uri(uri) def rebuild_relative_uri(uri)
file_path = nested_file_path_if_exists(uri) file_path = nested_file_path_if_exists(uri)
resource_type = uri_type(file_path)
# Repository routes are under /-/ scope now.
# Since we craft a path without using route helpers we must
# ensure - is added here.
prefix = '-' if %w(tree blob raw commits).include?(resource_type.to_s)
uri.path = [ uri.path = [
relative_url_root, relative_url_root,
project.full_path, project.full_path,
uri_type(file_path), prefix,
resource_type,
Addressable::URI.escape(ref).gsub('#', '%23'), Addressable::URI.escape(ref).gsub('#', '%23'),
Addressable::URI.escape(file_path) Addressable::URI.escape(file_path)
].compact.join('/').squeeze('/').chomp('/') ].compact.join('/').squeeze('/').chomp('/')
......
...@@ -12,10 +12,12 @@ module Gitlab ...@@ -12,10 +12,12 @@ module Gitlab
def link_dependencies def link_dependencies
link_json('ImportPath') do |path| link_json('ImportPath') do |path|
case path case path
when %r{\A(?<repo>github\.com/#{REPO_REGEX})/(?<path>.+)\z}
"https://#{$~[:repo]}/tree/master/#{$~[:path]}"
when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z}, when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z},
%r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z} %r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z}
"https://#{$~[:repo]}/tree/master/#{$~[:path]}" "https://#{$~[:repo]}/-/tree/master/#{$~[:path]}"
when /\Agolang\.org/ when /\Agolang\.org/
"https://godoc.org/#{path}" "https://godoc.org/#{path}"
else else
......
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
end end
meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}" meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}"
meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}" meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}"
head_tag = content_tag :head, meta_import_tag + meta_source_tag head_tag = content_tag :head, meta_import_tag + meta_source_tag
html_tag = content_tag :html, head_tag + body_tag html_tag = content_tag :html, head_tag + body_tag
[html_tag, 200] [html_tag, 200]
......
...@@ -72,7 +72,7 @@ describe MetricsDashboard do ...@@ -72,7 +72,7 @@ describe MetricsDashboard do
it 'includes project_blob_path only for project dashboards' do it 'includes project_blob_path only for project dashboards' do
expect(system_dashboard['project_blob_path']).to be_nil expect(system_dashboard['project_blob_path']).to be_nil
expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/blob/master/.gitlab/dashboards/test.yml") expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml")
end end
describe 'project permissions' do describe 'project permissions' do
......
...@@ -36,7 +36,7 @@ describe Projects::BlameController do ...@@ -36,7 +36,7 @@ describe Projects::BlameController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/master") .to redirect_to("/#{project.full_path}/-/tree/master")
end end
end end
......
...@@ -33,7 +33,7 @@ describe Projects::BlobController do ...@@ -33,7 +33,7 @@ describe Projects::BlobController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/master") .to redirect_to("/#{project.full_path}/-/tree/master")
end end
end end
...@@ -115,7 +115,7 @@ describe Projects::BlobController do ...@@ -115,7 +115,7 @@ describe Projects::BlobController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/markdown/doc") .to redirect_to("/#{project.full_path}/-/tree/markdown/doc")
end end
end end
end end
......
...@@ -38,7 +38,7 @@ describe Projects::BranchesController do ...@@ -38,7 +38,7 @@ describe Projects::BranchesController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/merge_branch") .to redirect_to("/#{project.full_path}/-/tree/merge_branch")
end end
end end
...@@ -48,7 +48,7 @@ describe Projects::BranchesController do ...@@ -48,7 +48,7 @@ describe Projects::BranchesController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/alert('merge');") .to redirect_to("/#{project.full_path}/-/tree/alert('merge');")
end end
end end
...@@ -93,7 +93,7 @@ describe Projects::BranchesController do ...@@ -93,7 +93,7 @@ describe Projects::BranchesController do
} }
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/1-feature-branch") .to redirect_to("/#{project.full_path}/-/tree/1-feature-branch")
end end
it 'posts a system note' do it 'posts a system note' do
......
...@@ -72,7 +72,7 @@ describe Projects::RawController do ...@@ -72,7 +72,7 @@ describe Projects::RawController do
env: :raw_blob_request_limit, env: :raw_blob_request_limit,
remote_ip: '0.0.0.0', remote_ip: '0.0.0.0',
request_method: 'GET', request_method: 'GET',
path: "/#{project.full_path}/raw/#{file_path}" path: "/#{project.full_path}/-/raw/#{file_path}"
} }
expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once
......
...@@ -45,7 +45,7 @@ describe Projects::TreeController do ...@@ -45,7 +45,7 @@ describe Projects::TreeController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/master") .to redirect_to("/#{project.full_path}/-/tree/master")
end end
end end
...@@ -60,7 +60,7 @@ describe Projects::TreeController do ...@@ -60,7 +60,7 @@ describe Projects::TreeController do
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/empty-branch") .to redirect_to("/#{project.full_path}/-/tree/empty-branch")
end end
end end
...@@ -153,7 +153,7 @@ describe Projects::TreeController do ...@@ -153,7 +153,7 @@ describe Projects::TreeController do
let(:id) { 'master/README.md' } let(:id) { 'master/README.md' }
it 'redirects' do it 'redirects' do
redirect_url = "/#{project.full_path}/blob/master/README.md" redirect_url = "/#{project.full_path}/-/blob/master/README.md"
expect(subject) expect(subject)
.to redirect_to(redirect_url) .to redirect_to(redirect_url)
end end
...@@ -181,7 +181,7 @@ describe Projects::TreeController do ...@@ -181,7 +181,7 @@ describe Projects::TreeController do
it 'redirects to the new directory' do it 'redirects to the new directory' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/#{branch_name}/#{path}") .to redirect_to("/#{project.full_path}/-/tree/#{branch_name}/#{path}")
expect(flash[:notice]).to eq('The directory has been successfully created.') expect(flash[:notice]).to eq('The directory has been successfully created.')
end end
end end
...@@ -192,7 +192,7 @@ describe Projects::TreeController do ...@@ -192,7 +192,7 @@ describe Projects::TreeController do
it 'does not allow overwriting of existing files' do it 'does not allow overwriting of existing files' do
expect(subject) expect(subject)
.to redirect_to("/#{project.full_path}/tree/master") .to redirect_to("/#{project.full_path}/-/tree/master")
expect(flash[:alert]).to eq('A file with this name already exists') expect(flash[:alert]).to eq('A file with this name already exists')
end end
end end
......
...@@ -973,7 +973,7 @@ describe ProjectsController do ...@@ -973,7 +973,7 @@ describe ProjectsController do
end end
it 'renders JSON body with image links expanded' do it 'renders JSON body with image links expanded' do
expanded_path = "/#{project_with_repo.full_path}/raw/master/files/images/logo-white.png" expanded_path = "/#{project_with_repo.full_path}/-/raw/master/files/images/logo-white.png"
post :preview_markdown, params: preview_markdown_params post :preview_markdown, params: preview_markdown_params
......
...@@ -97,7 +97,7 @@ describe('IDE services', () => { ...@@ -97,7 +97,7 @@ describe('IDE services', () => {
mock mock
.onGet( .onGet(
`${relativeUrlRoot}/${TEST_PROJECT_ID}/raw/${TEST_COMMIT_SHA}/${escapeFileUrl( `${relativeUrlRoot}/${TEST_PROJECT_ID}/-/raw/${TEST_COMMIT_SHA}/${escapeFileUrl(
filePath, filePath,
)}`, )}`,
) )
......
...@@ -32,8 +32,8 @@ describe('Repository parent row component', () => { ...@@ -32,8 +32,8 @@ describe('Repository parent row component', () => {
it.each` it.each`
path | to path | to
${'app'} | ${'/tree/master/'} ${'app'} | ${'/-/tree/master/'}
${'app/assets'} | ${'/tree/master/app'} ${'app/assets'} | ${'/-/tree/master/app'}
`('renders link in $path to $to', ({ path, to }) => { `('renders link in $path to $to', ({ path, to }) => {
factory(path); factory(path);
...@@ -48,7 +48,7 @@ describe('Repository parent row component', () => { ...@@ -48,7 +48,7 @@ describe('Repository parent row component', () => {
vm.find('td').trigger('click'); vm.find('td').trigger('click');
expect($router.push).toHaveBeenCalledWith({ expect($router.push).toHaveBeenCalledWith({
path: '/tree/master/app', path: '/-/tree/master/app',
}); });
}); });
...@@ -60,7 +60,7 @@ describe('Repository parent row component', () => { ...@@ -60,7 +60,7 @@ describe('Repository parent row component', () => {
vm.find('a').trigger('click'); vm.find('a').trigger('click');
expect($router.push).not.toHaveBeenCalledWith({ expect($router.push).not.toHaveBeenCalledWith({
path: '/tree/master/app', path: '/-/tree/master/app',
}); });
}); });
......
...@@ -88,7 +88,7 @@ describe('Repository table row component', () => { ...@@ -88,7 +88,7 @@ describe('Repository table row component', () => {
vm.trigger('click'); vm.trigger('click');
if (pushes) { if (pushes) {
expect($router.push).toHaveBeenCalledWith({ path: '/tree/master/test' }); expect($router.push).toHaveBeenCalledWith({ path: '/-/tree/master/test' });
} else { } else {
expect($router.push).not.toHaveBeenCalled(); expect($router.push).not.toHaveBeenCalled();
} }
......
...@@ -4,11 +4,11 @@ import createRouter from '~/repository/router'; ...@@ -4,11 +4,11 @@ import createRouter from '~/repository/router';
describe('Repository router spec', () => { describe('Repository router spec', () => {
it.each` it.each`
path | component | componentName path | component | componentName
${'/'} | ${IndexPage} | ${'IndexPage'} ${'/'} | ${IndexPage} | ${'IndexPage'}
${'/tree/master'} | ${TreePage} | ${'TreePage'} ${'/-/tree/master'} | ${TreePage} | ${'TreePage'}
${'/tree/master/app/assets'} | ${TreePage} | ${'TreePage'} ${'/-/tree/master/app/assets'} | ${TreePage} | ${'TreePage'}
${'/tree/123/app/assets'} | ${null} | ${'null'} ${'/-/tree/123/app/assets'} | ${null} | ${'null'}
`('sets component as $componentName for path "$path"', ({ path, component }) => { `('sets component as $componentName for path "$path"', ({ path, component }) => {
const router = createRouter('', 'master'); const router = createRouter('', 'master');
......
...@@ -56,7 +56,7 @@ describe BlobHelper do ...@@ -56,7 +56,7 @@ describe BlobHelper do
stub_feature_flags(web_ide_default: false) stub_feature_flags(web_ide_default: false)
link = helper.edit_blob_button(project, 'master', 'README.md') link = helper.edit_blob_button(project, 'master', 'README.md')
expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md") expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md")
end end
it 'returns a link with a Web IDE route' do it 'returns a link with a Web IDE route' do
...@@ -69,7 +69,7 @@ describe BlobHelper do ...@@ -69,7 +69,7 @@ describe BlobHelper do
stub_feature_flags(web_ide_default: false) stub_feature_flags(web_ide_default: false)
link = helper.edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 }) link = helper.edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 })
expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md?mr_id=10") expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md?mr_id=10")
end end
end end
......
...@@ -103,7 +103,7 @@ describe MarkupHelper do ...@@ -103,7 +103,7 @@ describe MarkupHelper do
let(:requested_path) { 'files/images/README.md' } let(:requested_path) { 'files/images/README.md' }
it 'returns the correct HTML for the image' do it 'returns the correct HTML for the image' do
expanded_path = "/#{project.full_path}/raw/master/files/images/#{image_file}" expanded_path = "/#{project.full_path}/-/raw/master/files/images/#{image_file}"
expect(subject.css('a')[0].attr('href')).to eq(expanded_path) expect(subject.css('a')[0].attr('href')).to eq(expanded_path)
expect(subject.css('img')[0].attr('data-src')).to eq(expanded_path) expect(subject.css('img')[0].attr('data-src')).to eq(expanded_path)
......
...@@ -100,34 +100,34 @@ describe SubmoduleHelper do ...@@ -100,34 +100,34 @@ describe SubmoduleHelper do
allow(repo).to receive(:project).and_return(project) allow(repo).to receive(:project).and_return(project)
stub_url('./') stub_url('./')
expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"]) expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/-/tree/hash"])
end end
end end
context 'submodule on gitlab.com' do context 'submodule on gitlab.com' do
it 'detects ssh' do it 'detects ssh' do
stub_url('git@gitlab.com:gitlab-org/gitlab-foss.git') stub_url('git@gitlab.com:gitlab-org/gitlab-foss.git')
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
end end
it 'detects http' do it 'detects http' do
stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git') stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git')
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
end end
it 'detects https' do it 'detects https' do
stub_url('https://gitlab.com/gitlab-org/gitlab-foss.git') stub_url('https://gitlab.com/gitlab-org/gitlab-foss.git')
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
end end
it 'handles urls with no .git on the end' do it 'handles urls with no .git on the end' do
stub_url('http://gitlab.com/gitlab-org/gitlab-foss') stub_url('http://gitlab.com/gitlab-org/gitlab-foss')
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
end end
it 'handles urls with trailing whitespace' do it 'handles urls with trailing whitespace' do
stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git ') stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git ')
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
end end
it 'returns original with non-standard url' do it 'returns original with non-standard url' do
...@@ -171,7 +171,7 @@ describe SubmoduleHelper do ...@@ -171,7 +171,7 @@ describe SubmoduleHelper do
stub_url(relative_path) stub_url(relative_path)
result = subject result = subject
expect(result).to eq([expected_path, "#{expected_path}/tree/#{submodule_item.id}"]) expect(result).to eq([expected_path, "#{expected_path}/-/tree/#{submodule_item.id}"])
end end
it 'handles project under same group' do it 'handles project under same group' do
......
...@@ -38,11 +38,11 @@ describe('DiffViewer', () => { ...@@ -38,11 +38,11 @@ describe('DiffViewer', () => {
setTimeout(() => { setTimeout(() => {
expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe( expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe(
`//raw/DEF/${RED_BOX_IMAGE_URL}`, `//-/raw/DEF/${RED_BOX_IMAGE_URL}`,
); );
expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe( expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe(
`//raw/ABC/${GREEN_BOX_IMAGE_URL}`, `//-/raw/ABC/${GREEN_BOX_IMAGE_URL}`,
); );
done(); done();
......
...@@ -152,7 +152,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -152,7 +152,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
it 'rebuilds absolute URL for a file in the repo' do it 'rebuilds absolute URL for a file in the repo' do
doc = filter(link('/doc/api/README.md')) doc = filter(link('/doc/api/README.md'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md"
end end
it 'does not modify relative URLs in system notes' do it 'does not modify relative URLs in system notes' do
...@@ -170,13 +170,13 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -170,13 +170,13 @@ describe Banzai::Filter::RepositoryLinkFilter do
it 'rebuilds relative URL for a file in the repo' do it 'rebuilds relative URL for a file in the repo' do
doc = filter(link('doc/api/README.md')) doc = filter(link('doc/api/README.md'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md"
end end
it 'rebuilds relative URL for a file in the repo with leading ./' do it 'rebuilds relative URL for a file in the repo with leading ./' do
doc = filter(link('./doc/api/README.md')) doc = filter(link('./doc/api/README.md'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md"
end end
it 'rebuilds relative URL for a file in the repo up one directory' do it 'rebuilds relative URL for a file in the repo up one directory' do
...@@ -184,7 +184,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -184,7 +184,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md') doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md')
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md"
end end
it 'rebuilds relative URL for a file in the repo up multiple directories' do it 'rebuilds relative URL for a file in the repo up multiple directories' do
...@@ -192,7 +192,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -192,7 +192,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md') doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md')
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md"
end end
it 'rebuilds relative URL for a file in the repository root' do it 'rebuilds relative URL for a file in the repository root' do
...@@ -200,47 +200,47 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -200,47 +200,47 @@ describe Banzai::Filter::RepositoryLinkFilter do
doc = filter(relative_link, requested_path: 'doc/some-file.md') doc = filter(relative_link, requested_path: 'doc/some-file.md')
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/README.md" .to eq "/#{project_path}/-/blob/#{ref}/README.md"
end end
it 'rebuilds relative URL for a file in the repo with an anchor' do it 'rebuilds relative URL for a file in the repo with an anchor' do
doc = filter(link('README.md#section')) doc = filter(link('README.md#section'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/blob/#{ref}/README.md#section" .to eq "/#{project_path}/-/blob/#{ref}/README.md#section"
end end
it 'rebuilds relative URL for a directory in the repo' do it 'rebuilds relative URL for a directory in the repo' do
doc = filter(link('doc/api/')) doc = filter(link('doc/api/'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/tree/#{ref}/doc/api" .to eq "/#{project_path}/-/tree/#{ref}/doc/api"
end end
it 'rebuilds relative URL for an image in the repo' do it 'rebuilds relative URL for an image in the repo' do
doc = filter(image('files/images/logo-black.png')) doc = filter(image('files/images/logo-black.png'))
expect(doc.at_css('img')['src']) expect(doc.at_css('img')['src'])
.to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" .to eq "/#{project_path}/-/raw/#{ref}/files/images/logo-black.png"
end end
it 'rebuilds relative URL for link to an image in the repo' do it 'rebuilds relative URL for link to an image in the repo' do
doc = filter(link('files/images/logo-black.png')) doc = filter(link('files/images/logo-black.png'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" .to eq "/#{project_path}/-/raw/#{ref}/files/images/logo-black.png"
end end
it 'rebuilds relative URL for a video in the repo' do it 'rebuilds relative URL for a video in the repo' do
doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video') doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video')
expect(doc.at_css('video')['src']) expect(doc.at_css('video')['src'])
.to eq "/#{project_path}/raw/video/files/videos/intro.mp4" .to eq "/#{project_path}/-/raw/video/files/videos/intro.mp4"
end end
it 'rebuilds relative URL for audio in the repo' do it 'rebuilds relative URL for audio in the repo' do
doc = filter(audio('files/audio/sample.wav'), commit: project.commit('audio'), ref: 'audio') doc = filter(audio('files/audio/sample.wav'), commit: project.commit('audio'), ref: 'audio')
expect(doc.at_css('audio')['src']) expect(doc.at_css('audio')['src'])
.to eq "/#{project_path}/raw/audio/files/audio/sample.wav" .to eq "/#{project_path}/-/raw/audio/files/audio/sample.wav"
end end
it 'does not modify relative URL with an anchor only' do it 'does not modify relative URL with an anchor only' do
...@@ -267,7 +267,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -267,7 +267,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw) allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw)
doc = filter(image(escaped)) doc = filter(image(escaped))
expect(doc.at_css('img')['src']).to eq "/#{project_path}/raw/#{Addressable::URI.escape(ref)}/#{escaped}" expect(doc.at_css('img')['src']).to eq "/#{project_path}/-/raw/#{Addressable::URI.escape(ref)}/#{escaped}"
end end
context 'when requested path is a file in the repo' do context 'when requested path is a file in the repo' do
...@@ -275,7 +275,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -275,7 +275,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
it 'rebuilds URL relative to the containing directory' do it 'rebuilds URL relative to the containing directory' do
doc = filter(link('users.md')) doc = filter(link('users.md'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
end end
end end
...@@ -284,7 +284,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -284,7 +284,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
it 'rebuilds URL relative to the directory' do it 'rebuilds URL relative to the directory' do
doc = filter(link('users.md')) doc = filter(link('users.md'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
end end
end end
...@@ -295,7 +295,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -295,7 +295,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
it 'correctly escapes the ref' do it 'correctly escapes the ref' do
doc = filter(link('.gitkeep')) doc = filter(link('.gitkeep'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep" expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep"
end end
end end
...@@ -314,7 +314,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -314,7 +314,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
doc = filter(link(path)) doc = filter(link(path))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/raw/#{ref_escaped}/files/images/logo-black.png" .to eq "/#{project_path}/-/raw/#{ref_escaped}/files/images/logo-black.png"
end end
end end
...@@ -325,7 +325,7 @@ describe Banzai::Filter::RepositoryLinkFilter do ...@@ -325,7 +325,7 @@ describe Banzai::Filter::RepositoryLinkFilter do
it 'does not escape the space twice' do it 'does not escape the space twice' do
doc = filter(link('README.md')) doc = filter(link('README.md'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md" expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md"
end end
end end
end end
......
...@@ -31,7 +31,7 @@ describe ExtractsPath do ...@@ -31,7 +31,7 @@ describe ExtractsPath do
it "log tree path has no escape sequences" do it "log tree path has no escape sequences" do
assign_ref_vars assign_ref_vars
expect(@logs_path).to eq("/#{@project.full_path}/refs/#{ref}/logs_tree/files/ruby/popen.rb") expect(@logs_path).to eq("/#{@project.full_path}/-/refs/#{ref}/logs_tree/files/ruby/popen.rb")
end end
context 'ref contains %20' do context 'ref contains %20' do
......
...@@ -258,7 +258,7 @@ FILE ...@@ -258,7 +258,7 @@ FILE
describe '#as_json' do describe '#as_json' do
it 'includes the blob path for the file' do it 'includes the blob path for the file' do
expect(conflict_file.as_json[:blob_path]) expect(conflict_file.as_json[:blob_path])
.to eq("/#{project.full_path}/blob/#{our_commit.oid}/files/ruby/regex.rb") .to eq("/#{project.full_path}/-/blob/#{our_commit.oid}/files/ruby/regex.rb")
end end
it 'includes the blob icon for the file' do it 'includes the blob icon for the file' do
......
...@@ -75,8 +75,8 @@ describe Gitlab::DependencyLinker::GodepsJsonLinker do ...@@ -75,8 +75,8 @@ describe Gitlab::DependencyLinker::GodepsJsonLinker do
end end
it 'links GitLab projects' do it 'links GitLab projects' do
expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/tree/master/path')) expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/-/tree/master/path'))
expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/tree/master/path')) expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/-/tree/master/path'))
end end
it 'links Golang packages' do it 'links Golang packages' do
......
...@@ -21,7 +21,7 @@ describe Gitlab::Graphql::Representation::SubmoduleTreeEntry do ...@@ -21,7 +21,7 @@ describe Gitlab::Graphql::Representation::SubmoduleTreeEntry do
) )
expect(entries.map(&:tree_url)).to contain_exactly( expect(entries.map(&:tree_url)).to contain_exactly(
"https://gitlab.com/gitlab-org/gitlab-grack/tree/645f6c4c82fd3f5e06f67134450a570b795e55a6", "https://gitlab.com/gitlab-org/gitlab-grack/-/tree/645f6c4c82fd3f5e06f67134450a570b795e55a6",
"https://github.com/gitlabhq/gitlab-shell/tree/79bceae69cb5750d6567b223597999bfa91cb3b9", "https://github.com/gitlabhq/gitlab-shell/tree/79bceae69cb5750d6567b223597999bfa91cb3b9",
"https://github.com/randx/six/tree/409f37c4f05865e4fb208c771485f211a22c4c2d" "https://github.com/randx/six/tree/409f37c4f05865e4fb208c771485f211a22c4c2d"
) )
......
...@@ -241,7 +241,7 @@ describe Gitlab::Middleware::Go do ...@@ -241,7 +241,7 @@ describe Gitlab::Middleware::Go do
project_url = "http://#{Gitlab.config.gitlab.host}/#{path}" project_url = "http://#{Gitlab.config.gitlab.host}/#{path}"
expect(response[0]).to eq(200) expect(response[0]).to eq(200)
expect(response[1]['Content-Type']).to eq('text/html') expect(response[1]['Content-Type']).to eq('text/html')
expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}" /></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>} expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}" /></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>}
expect(response[2].body).to eq([expected_body]) expect(response[2].body).to eq([expected_body])
end end
end end
......
...@@ -38,7 +38,7 @@ describe Gitlab::SubmoduleLinks do ...@@ -38,7 +38,7 @@ describe Gitlab::SubmoduleLinks do
end end
it 'returns links and caches the by ref' do it 'returns links and caches the by ref' do
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
cache_store = links.instance_variable_get("@cache_store") cache_store = links.instance_variable_get("@cache_store")
...@@ -49,7 +49,7 @@ describe Gitlab::SubmoduleLinks do ...@@ -49,7 +49,7 @@ describe Gitlab::SubmoduleLinks do
let(:ref) { 'signed-commits' } let(:ref) { 'signed-commits' }
it 'returns links' do it 'returns links' do
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
end end
end end
end end
......
...@@ -725,7 +725,7 @@ describe Project do ...@@ -725,7 +725,7 @@ describe Project do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
it 'returns the README' do it 'returns the README' do
expect(project.readme_url).to eq("#{project.web_url}/blob/master/README.md") expect(project.readme_url).to eq("#{project.web_url}/-/blob/master/README.md")
end end
end end
end end
......
...@@ -21,7 +21,7 @@ describe BlobPresenter, :seed_helper do ...@@ -21,7 +21,7 @@ describe BlobPresenter, :seed_helper do
subject { described_class.new(blob) } subject { described_class.new(blob) }
it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/blob/#{blob.commit_id}/#{blob.path}") } it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/-/blob/#{blob.commit_id}/#{blob.path}") }
end end
describe '#highlight' do describe '#highlight' do
......
...@@ -334,7 +334,7 @@ describe MergeRequestPresenter do ...@@ -334,7 +334,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:target_branch_exists?) { true } allow(resource).to receive(:target_branch_exists?) { true }
is_expected is_expected
.to eq("/#{resource.target_project.full_path}/commits/#{resource.target_branch}") .to eq("/#{resource.target_project.full_path}/-/commits/#{resource.target_branch}")
end end
end end
...@@ -358,7 +358,7 @@ describe MergeRequestPresenter do ...@@ -358,7 +358,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:source_branch_exists?) { true } allow(resource).to receive(:source_branch_exists?) { true }
is_expected is_expected
.to eq("/#{resource.source_project.full_path}/commits/#{resource.source_branch}") .to eq("/#{resource.source_project.full_path}/-/commits/#{resource.source_branch}")
end end
end end
...@@ -382,7 +382,7 @@ describe MergeRequestPresenter do ...@@ -382,7 +382,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:target_branch_exists?) { true } allow(resource).to receive(:target_branch_exists?) { true }
is_expected is_expected
.to eq("/#{resource.target_project.full_path}/tree/#{resource.target_branch}") .to eq("/#{resource.target_project.full_path}/-/tree/#{resource.target_branch}")
end end
end end
...@@ -496,7 +496,7 @@ describe MergeRequestPresenter do ...@@ -496,7 +496,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:source_branch_exists?) { true } allow(resource).to receive(:source_branch_exists?) { true }
is_expected is_expected
.to eq("<a href=\"/#{resource.source_project.full_path}/tree/#{resource.source_branch}\">#{resource.source_branch}</a>") .to eq("<a href=\"/#{resource.source_project.full_path}/-/tree/#{resource.source_branch}\">#{resource.source_branch}</a>")
end end
it 'escapes html, when source_branch does not exist' do it 'escapes html, when source_branch does not exist' do
......
...@@ -11,6 +11,6 @@ describe TreeEntryPresenter do ...@@ -11,6 +11,6 @@ describe TreeEntryPresenter do
let(:presenter) { described_class.new(tree) } let(:presenter) { described_class.new(tree) }
describe '.web_url' do describe '.web_url' do
it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/tree/#{tree.commit_id}/#{tree.path}") } it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/tree/#{tree.commit_id}/#{tree.path}") }
end end
end end
...@@ -812,7 +812,7 @@ describe API::Projects do ...@@ -812,7 +812,7 @@ describe API::Projects do
post api('/projects', user), params: project post api('/projects', user), params: project
expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/blob/master/README.md") expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/-/blob/master/README.md")
end end
it 'sets tag list to a project' do it 'sets tag list to a project' do
......
...@@ -834,7 +834,7 @@ describe 'Git HTTP requests' do ...@@ -834,7 +834,7 @@ describe 'Git HTTP requests' do
Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project) Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project)
end end
get "/#{project.full_path}/blob/master/info/refs" get "/#{project.full_path}/-/blob/master/info/refs"
end end
it "returns the file" do it "returns the file" do
...@@ -844,7 +844,7 @@ describe 'Git HTTP requests' do ...@@ -844,7 +844,7 @@ describe 'Git HTTP requests' do
context "when the file does not exist" do context "when the file does not exist" do
before do before do
get "/#{project.full_path}/blob/master/info/refs" get "/#{project.full_path}/-/blob/master/info/refs"
end end
it "redirects" do it "redirects" do
......
This diff is collapsed.
...@@ -23,7 +23,7 @@ describe BlobEntity do ...@@ -23,7 +23,7 @@ describe BlobEntity do
mode: "100644", mode: "100644",
readable_text: true, readable_text: true,
icon: "file-text-o", icon: "file-text-o",
url: "/#{project.full_path}/blob/master/bar/branch-test.txt" url: "/#{project.full_path}/-/blob/master/bar/branch-test.txt"
}) })
end end
end end
......
...@@ -60,7 +60,7 @@ describe MergeRequestPollWidgetEntity do ...@@ -60,7 +60,7 @@ describe MergeRequestPollWidgetEntity do
project.add_developer(user) project.add_developer(user)
expect(subject[:new_blob_path]) expect(subject[:new_blob_path])
.to eq("/#{resource.project.full_path}/new/#{resource.source_branch}") .to eq("/#{resource.project.full_path}/-/new/#{resource.source_branch}")
end end
end end
......
...@@ -40,7 +40,7 @@ describe 'help/index' do ...@@ -40,7 +40,7 @@ describe 'help/index' do
render render
expect(rendered).to match '8.0.2' expect(rendered).to match '8.0.2'
expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/commits/abcdefg}) expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/-/commits/abcdefg})
end end
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