Commit 6b9eb4d6 authored by Alessio Caiazza's avatar Alessio Caiazza

Revert "Merge branch 'dz-scope-repository-routes' into 'master'"

This reverts merge request !20455
parent 13e60a2b
......@@ -104,10 +104,10 @@ export default {
return acc.concat({
name,
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() {
......
......@@ -15,7 +15,7 @@ export default {
const splitArray = this.path.split('/');
splitArray.pop();
return { path: `/-/tree/${this.commitRef}/${splitArray.join('/')}` };
return { path: `/tree/${this.commitRef}/${splitArray.join('/')}` };
},
},
methods: {
......
......@@ -84,7 +84,7 @@ export default {
},
computed: {
routerLinkTo() {
return this.isFolder ? { path: `/-/tree/${this.ref}/${this.path}` } : null;
return this.isFolder ? { path: `/tree/${this.ref}/${this.path}` } : null;
},
iconName() {
return `fa-${getIconName(this.type, this.path)}`;
......
......@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) {
base: joinPaths(gon.relative_url_root || '', base),
routes: [
{
path: `/-/tree/${baseRef}(/.*)?`,
path: `/tree/${baseRef}(/.*)?`,
name: 'treePath',
component: TreePage,
props: route => ({
......
......@@ -79,10 +79,10 @@ export default {
return this.projectPath.indexOf('/') === 0 ? '' : `${gon.relative_url_root}/`;
},
fullOldPath() {
return `${this.basePath}${this.projectPath}/-/raw/${this.oldSha}/${this.oldPath}`;
return `${this.basePath}${this.projectPath}/raw/${this.oldSha}/${this.oldPath}`;
},
fullNewPath() {
return `${this.basePath}${this.projectPath}/-/raw/${this.newSha}/${this.newPath}`;
return `${this.basePath}${this.projectPath}/raw/${this.newSha}/${this.newPath}`;
},
},
};
......
......@@ -43,8 +43,6 @@ module SubmoduleHelper
elsif github_dot_com_url?(url)
standard_links('github.com', namespace, project, submodule_item_id)
elsif gitlab_dot_com_url?(url)
# This need to be replaced with /-/tree routing once one is landed on
# GitLab.com. Issue https://gitlab.com/gitlab-org/gitlab/issues/42764
standard_links('gitlab.com', namespace, project, submodule_item_id)
else
[sanitize_submodule_url(url), nil]
......
......@@ -38,13 +38,13 @@ module TreeHelper
# many paths, as with a repository tree that has thousands of items.
def fast_project_blob_path(project, blob_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
def fast_project_tree_path(project, tree_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
......
---
title: Move repository routes under - scope
merge_request: 20455
author:
type: deprecated
......@@ -554,8 +554,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
:forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers,
:environments, :protected_environments, :error_tracking,
:serverless, :clusters, :audit_events, :wikis, :merge_requests,
:blob, :tree, :raw, :blame, :commits, :create_dir, :find_file, :files)
:serverless, :clusters, :audit_events, :wikis, :merge_requests)
end
# rubocop: disable Cop/PutProjectRoutesUnderScope
......
......@@ -65,7 +65,7 @@ scope format: false do
resources :protected_tags, only: [:index, :show, :create, :update, :destroy]
end
scope path: '-', constraints: { id: /[^\0]+/ } do
scope constraints: { id: /[^\0]+/ } do
scope controller: :blob do
get '/new/*id', action: :new, as: :new_blob
post '/create/*id', action: :create, as: :create_blob
......
......@@ -36,7 +36,7 @@ const GUIDED_GITLAB_TOUR = [
},
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/tree/master$`, ''),
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/tree/master$`, ''),
getHelpContent: ({ projectName }) => [
{
text: sprintf(
......@@ -69,7 +69,7 @@ const GUIDED_GITLAB_TOUR = [
},
},
{
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/commits/master$`, ''),
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commits/master$`, ''),
getHelpContent: () => [
{
text: s__(
......
......@@ -245,7 +245,7 @@ scope path: '(/-/jira)', constraints: ::Constraints::JiraEncodedUrlConstrainer.n
project: params[:project_id]
)
"/#{project_full_path}/-/tree/#{params[:id]}"
"/#{project_full_path}/tree/#{params[:id]}"
}
end
end
......@@ -12,7 +12,7 @@
"deployed_at": "2019-02-20T16:15:40.122Z",
"ref": {
"name": "master",
"ref_path": "/root/minimal-ruby-app/-/tree/master",
"ref_path": "/root/minimal-ruby-app/tree/master",
"tag": false
},
"created_at": "2019-02-20T16:09:12.213Z",
......
......@@ -12,7 +12,7 @@ describe EE::VersionCheckHelper do
end
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
......
......@@ -19,7 +19,7 @@ describe Gitlab::Ci::Parsers::Security::DependencyList do
let(:artifact) { create(:ee_ci_job_artifact, :dependency_list) }
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[0][:name]).to eq('mini_portile2')
......
......@@ -20,7 +20,7 @@ describe Gitlab::Ci::Parsers::Security::Formatters::DependencyList do
let(:package_manager) { 'bundler' }
let(:file_path) { 'rails/Gemfile.lock' }
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
let(:dependency) { parsed_report['dependency_files'][0]['dependencies'][0] }
......
......@@ -247,7 +247,7 @@ describe Ci::Build do
it 'parses blobs and add the results to the report' do
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]
yarn = dependency_list_report.dependencies[20]
......
......@@ -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@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/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
with_them do
......@@ -50,7 +50,7 @@ describe 'Jira referenced paths', type: :request do
where(:jira_path, :redirect_path) do
'/-/jira/group/group_project' | '/group/group_project'
'/-/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
with_them do
......
......@@ -152,18 +152,11 @@ module Banzai
def rebuild_relative_uri(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 = [
relative_url_root,
project.full_path,
prefix,
resource_type,
uri_type(file_path),
Addressable::URI.escape(ref).gsub('#', '%23'),
Addressable::URI.escape(file_path)
].compact.join('/').squeeze('/').chomp('/')
......
......@@ -12,12 +12,10 @@ module Gitlab
def link_dependencies
link_json('ImportPath') do |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},
%r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z}
%r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z}
"https://#{$~[:repo]}/-/tree/master/#{$~[:path]}"
"https://#{$~[:repo]}/tree/master/#{$~[:path]}"
when /\Agolang\.org/
"https://godoc.org/#{path}"
else
......
......@@ -60,7 +60,7 @@ module Gitlab
end
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
html_tag = content_tag :html, head_tag + body_tag
[html_tag, 200]
......
......@@ -72,7 +72,7 @@ describe MetricsDashboard do
it 'includes project_blob_path only for project dashboards' do
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
describe 'project permissions' do
......
......@@ -36,7 +36,7 @@ describe Projects::BlameController do
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/master")
.to redirect_to("/#{project.full_path}/tree/master")
end
end
......
......@@ -33,7 +33,7 @@ describe Projects::BlobController do
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/master")
.to redirect_to("/#{project.full_path}/tree/master")
end
end
......@@ -115,7 +115,7 @@ describe Projects::BlobController do
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/markdown/doc")
.to redirect_to("/#{project.full_path}/tree/markdown/doc")
end
end
end
......
......@@ -37,7 +37,7 @@ describe Projects::BranchesController do
let(:ref) { "master" }
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/merge_branch")
.to redirect_to("/#{project.full_path}/tree/merge_branch")
end
end
......@@ -46,7 +46,7 @@ describe Projects::BranchesController do
let(:ref) { "master" }
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/alert('merge');")
.to redirect_to("/#{project.full_path}/tree/alert('merge');")
end
end
......@@ -88,7 +88,7 @@ describe Projects::BranchesController do
}
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/1-feature-branch")
.to redirect_to("/#{project.full_path}/tree/1-feature-branch")
end
it 'posts a system note' do
......
......@@ -69,7 +69,7 @@ describe Projects::RawController do
env: :raw_blob_request_limit,
remote_ip: '0.0.0.0',
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
......
......@@ -45,7 +45,7 @@ describe Projects::TreeController do
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/master")
.to redirect_to("/#{project.full_path}/tree/master")
end
end
......@@ -60,7 +60,7 @@ describe Projects::TreeController do
it 'redirects' do
expect(subject)
.to redirect_to("/#{project.full_path}/-/tree/empty-branch")
.to redirect_to("/#{project.full_path}/tree/empty-branch")
end
end
......@@ -125,7 +125,7 @@ describe Projects::TreeController do
let(:id) { 'master/README.md' }
it 'redirects' do
redirect_url = "/#{project.full_path}/-/blob/master/README.md"
redirect_url = "/#{project.full_path}/blob/master/README.md"
expect(subject)
.to redirect_to(redirect_url)
end
......@@ -153,7 +153,7 @@ describe Projects::TreeController do
it 'redirects to the new directory' do
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.')
end
end
......@@ -164,7 +164,7 @@ describe Projects::TreeController do
it 'does not allow overwriting of existing files' do
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')
end
end
......
......@@ -943,7 +943,7 @@ describe ProjectsController do
end
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
......
......@@ -30,8 +30,8 @@ describe('Repository parent row component', () => {
it.each`
path | to
${'app'} | ${'/-/tree/master/'}
${'app/assets'} | ${'/-/tree/master/app'}
${'app'} | ${'/tree/master/'}
${'app/assets'} | ${'/tree/master/app'}
`('renders link in $path to $to', ({ path, to }) => {
factory(path);
......@@ -46,7 +46,7 @@ describe('Repository parent row component', () => {
vm.find('td').trigger('click');
expect($router.push).toHaveBeenCalledWith({
path: '/-/tree/master/app',
path: '/tree/master/app',
});
});
......@@ -58,7 +58,7 @@ describe('Repository parent row component', () => {
vm.find('a').trigger('click');
expect($router.push).not.toHaveBeenCalledWith({
path: '/-/tree/master/app',
path: '/tree/master/app',
});
});
});
......@@ -83,7 +83,7 @@ describe('Repository table row component', () => {
vm.trigger('click');
if (pushes) {
expect($router.push).toHaveBeenCalledWith({ path: '/-/tree/master/test' });
expect($router.push).toHaveBeenCalledWith({ path: '/tree/master/test' });
} else {
expect($router.push).not.toHaveBeenCalled();
}
......
......@@ -6,9 +6,9 @@ describe('Repository router spec', () => {
it.each`
path | component | componentName
${'/'} | ${IndexPage} | ${'IndexPage'}
${'/-/tree/master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/master/app/assets'} | ${TreePage} | ${'TreePage'}
${'/-/tree/123/app/assets'} | ${null} | ${'null'}
${'/tree/master'} | ${TreePage} | ${'TreePage'}
${'/tree/master/app/assets'} | ${TreePage} | ${'TreePage'}
${'/tree/123/app/assets'} | ${null} | ${'null'}
`('sets component as $componentName for path "$path"', ({ path, component }) => {
const router = createRouter('', 'master');
......
......@@ -56,7 +56,7 @@ describe BlobHelper do
stub_feature_flags(web_ide_default: false)
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
it 'returns a link with a Web IDE route' do
......@@ -69,7 +69,7 @@ describe BlobHelper do
stub_feature_flags(web_ide_default: false)
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
......
......@@ -103,7 +103,7 @@ describe MarkupHelper do
let(:requested_path) { 'files/images/README.md' }
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('img')[0].attr('data-src')).to eq(expanded_path)
......
......@@ -95,7 +95,7 @@ describe SubmoduleHelper do
allow(repo).to receive(:project).and_return(project)
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
......@@ -166,7 +166,7 @@ describe SubmoduleHelper do
allow(repo).to receive(:submodule_url_for).and_return(relative_path)
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
it 'handles project under same group' do
......
......@@ -38,11 +38,11 @@ describe('DiffViewer', () => {
setTimeout(() => {
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(
`//-/raw/ABC/${GREEN_BOX_IMAGE_URL}`,
`//raw/ABC/${GREEN_BOX_IMAGE_URL}`,
);
done();
......
......@@ -153,7 +153,7 @@ describe Banzai::Filter::RelativeLinkFilter do
it 'rebuilds absolute URL for a file in the repo' do
doc = filter(link('/doc/api/README.md'))
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
it 'does not modify relative URLs in system notes' do
......@@ -171,13 +171,13 @@ describe Banzai::Filter::RelativeLinkFilter do
it 'rebuilds relative URL for a file in the repo' do
doc = filter(link('doc/api/README.md'))
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
it 'rebuilds relative URL for a file in the repo with leading ./' do
doc = filter(link('./doc/api/README.md'))
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
it 'rebuilds relative URL for a file in the repo up one directory' do
......@@ -185,7 +185,7 @@ describe Banzai::Filter::RelativeLinkFilter do
doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md')
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
it 'rebuilds relative URL for a file in the repo up multiple directories' do
......@@ -193,7 +193,7 @@ describe Banzai::Filter::RelativeLinkFilter do
doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md')
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
it 'rebuilds relative URL for a file in the repository root' do
......@@ -201,47 +201,47 @@ describe Banzai::Filter::RelativeLinkFilter do
doc = filter(relative_link, requested_path: 'doc/some-file.md')
expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/-/blob/#{ref}/README.md"
.to eq "/#{project_path}/blob/#{ref}/README.md"
end
it 'rebuilds relative URL for a file in the repo with an anchor' do
doc = filter(link('README.md#section'))
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
it 'rebuilds relative URL for a directory in the repo' do
doc = filter(link('doc/api/'))
expect(doc.at_css('a')['href'])
.to eq "/#{project_path}/-/tree/#{ref}/doc/api"
.to eq "/#{project_path}/tree/#{ref}/doc/api"
end
it 'rebuilds relative URL for an image in the repo' do
doc = filter(image('files/images/logo-black.png'))
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
it 'rebuilds relative URL for link to an image in the repo' do
doc = filter(link('files/images/logo-black.png'))
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
it 'rebuilds relative URL for a video in the repo' do
doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video')
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
it 'rebuilds relative URL for audio in the repo' do
doc = filter(audio('files/audio/sample.wav'), commit: project.commit('audio'), ref: 'audio')
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
it 'does not modify relative URL with an anchor only' do
......@@ -268,7 +268,7 @@ describe Banzai::Filter::RelativeLinkFilter do
allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw)
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
context 'when requested path is a file in the repo' do
......@@ -276,7 +276,7 @@ describe Banzai::Filter::RelativeLinkFilter do
it 'rebuilds URL relative to the containing directory' do
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
......@@ -285,7 +285,7 @@ describe Banzai::Filter::RelativeLinkFilter do
it 'rebuilds URL relative to the directory' do
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
......@@ -296,7 +296,7 @@ describe Banzai::Filter::RelativeLinkFilter do
it 'correctly escapes the ref' do
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
......@@ -315,7 +315,7 @@ describe Banzai::Filter::RelativeLinkFilter do
doc = filter(link(path))
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
......@@ -326,7 +326,7 @@ describe Banzai::Filter::RelativeLinkFilter do
it 'does not escape the space twice' do
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
......
......@@ -258,7 +258,7 @@ FILE
describe '#as_json' do
it 'includes the blob path for the file' do
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
it 'includes the blob icon for the file' do
......
......@@ -75,8 +75,8 @@ describe Gitlab::DependencyLinker::GodepsJsonLinker do
end
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/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/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'))
end
it 'links Golang packages' do
......
......@@ -241,7 +241,7 @@ describe Gitlab::Middleware::Go do
project_url = "http://#{Gitlab.config.gitlab.host}/#{path}"
expect(response[0]).to eq(200)
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])
end
end
......
......@@ -697,7 +697,7 @@ describe Project do
let(:project) { create(:project, :repository) }
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
......
......@@ -21,7 +21,7 @@ describe BlobPresenter, :seed_helper do
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
describe '#highlight' do
......
......@@ -334,7 +334,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:target_branch_exists?) { true }
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
......@@ -358,7 +358,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:source_branch_exists?) { true }
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
......@@ -382,7 +382,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:target_branch_exists?) { true }
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
......@@ -496,7 +496,7 @@ describe MergeRequestPresenter do
allow(resource).to receive(:source_branch_exists?) { true }
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
it 'escapes html, when source_branch does not exist' do
......
......@@ -11,6 +11,6 @@ describe TreeEntryPresenter do
let(:presenter) { described_class.new(tree) }
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
......@@ -715,7 +715,7 @@ describe API::Projects do
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
it 'sets tag list to a project' do
......
......@@ -834,7 +834,7 @@ describe 'Git HTTP requests' do
Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project)
end
get "/#{project.full_path}/-/blob/master/info/refs"
get "/#{project.full_path}/blob/master/info/refs"
end
it "returns the file" do
......@@ -844,7 +844,7 @@ describe 'Git HTTP requests' do
context "when the file does not exist" do
before do
get "/#{project.full_path}/-/blob/master/info/refs"
get "/#{project.full_path}/blob/master/info/refs"
end
it "redirects" do
......
......@@ -454,14 +454,11 @@ describe 'project routing' do
it_behaves_like 'RESTful project resources' do
let(:actions) { [:show] }
let(:controller) { 'commits' }
let(:controller_path) { '/-/commits' }
end
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom')
expect(get('/gitlab/gitlabhq/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom')
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/commits/master.atom", "/gitlab/gitlabhq/-/commits/master.atom"
end
# project_project_members GET /:project_id/project_members(.:format) project_members#index
......@@ -553,68 +550,62 @@ describe 'project routing' do
# project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /[^\0]+/, project_id: /[^\/]+/}
describe Projects::BlameController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
expect(get('/gitlab/gitlabhq/-/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
expect(get('/gitlab/gitlabhq/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
expect(get('/gitlab/gitlabhq/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/blame/master/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/blame/master/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/blame', action: 'show',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: "master/#{newline_file}" })
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/blame/master/readme.md", "/gitlab/gitlabhq/-/blame/master/readme.md"
end
# project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /[^\0]+/, project_id: /[^\/]+/}
describe Projects::BlobController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
expect(get('/gitlab/gitlabhq/-/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb')
expect(get('/gitlab/gitlabhq/-/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js')
expect(get('/gitlab/gitlabhq/-/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
expect(get('/gitlab/gitlabhq/-/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js')
expect(get('/gitlab/gitlabhq/-/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js')
expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
expect(get('/gitlab/gitlabhq/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb')
expect(get('/gitlab/gitlabhq/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js')
expect(get('/gitlab/gitlabhq/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
expect(get('/gitlab/gitlabhq/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js')
expect(get('/gitlab/gitlabhq/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js')
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/blob/blob/master/blob/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/blob/blob/master/blob/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/blob', action: 'show',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: "blob/master/blob/#{newline_file}" })
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/blob/master/readme.md", "/gitlab/gitlabhq/-/blob/master/readme.md"
end
# project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /[^\0]+/, project_id: /[^\/]+/}
describe Projects::TreeController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
expect(get('/gitlab/gitlabhq/-/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
expect(get('/gitlab/gitlabhq/-/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files')
expect(get('/gitlab/gitlabhq/-/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files')
expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
expect(get('/gitlab/gitlabhq/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
expect(get('/gitlab/gitlabhq/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files')
expect(get('/gitlab/gitlabhq/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files')
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/tree/master/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/tree/master/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/tree', action: 'show',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: "master/#{newline_file}" })
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/tree/master/app", "/gitlab/gitlabhq/-/tree/master/app"
end
# project_find_file GET /:namespace_id/:project_id/find_file/*id(.:format) projects/find_file#show {:id=>/[^\0]+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/html/}
# project_files GET /:namespace_id/:project_id/files/*id(.:format) projects/find_file#list {:id=>/(?:[^.]|\.(?!json$))+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/json/}
describe Projects::FindFileController, 'routing' do
it 'to #show' do
expect(get('/gitlab/gitlabhq/-/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
expect(get('/gitlab/gitlabhq/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/find_file/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/find_file/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/find_file', action: 'show',
namespace_id: 'gitlab', project_id: 'gitlabhq',
......@@ -622,29 +613,26 @@ describe 'project routing' do
end
it 'to #list' do
expect(get('/gitlab/gitlabhq/-/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json')
expect(get('/gitlab/gitlabhq/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json')
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/files/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/files/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/find_file', action: 'list',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: "#{newline_file}" })
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/find_file/master", "/gitlab/gitlabhq/-/find_file/master"
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/files/master.json", "/gitlab/gitlabhq/-/files/master.json"
end
describe Projects::BlobController, 'routing' do
it 'to #edit' do
expect(get('/gitlab/gitlabhq/-/edit/master/app/models/project.rb')).to(
expect(get('/gitlab/gitlabhq/edit/master/app/models/project.rb')).to(
route_to('projects/blob#edit',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: 'master/app/models/project.rb'))
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/edit/master/docs/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/blob', action: 'edit',
namespace_id: 'gitlab', project_id: 'gitlabhq',
......@@ -652,13 +640,13 @@ describe 'project routing' do
end
it 'to #preview' do
expect(post('/gitlab/gitlabhq/-/preview/master/app/models/project.rb')).to(
expect(post('/gitlab/gitlabhq/preview/master/app/models/project.rb')).to(
route_to('projects/blob#preview',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: 'master/app/models/project.rb'))
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/edit/master/docs/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/blob', action: 'edit',
namespace_id: 'gitlab', project_id: 'gitlabhq',
......@@ -671,14 +659,12 @@ describe 'project routing' do
it 'to #show' do
newline_file = "new\n\nline.txt"
url_encoded_newline_file = ERB::Util.url_encode(newline_file)
assert_routing({ path: "/gitlab/gitlabhq/-/raw/master/#{url_encoded_newline_file}",
assert_routing({ path: "/gitlab/gitlabhq/raw/master/#{url_encoded_newline_file}",
method: :get },
{ controller: 'projects/raw', action: 'show',
namespace_id: 'gitlab', project_id: 'gitlabhq',
id: "master/#{newline_file}" })
end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/raw/master/app/models/project.rb", "/gitlab/gitlabhq/-/raw/master/app/models/project.rb"
end
# project_compare_index GET /:project_id/compare(.:format) compare#index {id: /[^\/]+/, project_id: /[^\/]+/}
......
......@@ -23,7 +23,7 @@ describe BlobEntity do
mode: "100644",
readable_text: true,
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
......
......@@ -60,7 +60,7 @@ describe MergeRequestPollWidgetEntity do
project.add_developer(user)
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
......
......@@ -40,7 +40,7 @@ describe 'help/index' do
render
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
......
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