Commit adce3a2c authored by Vasilii Iakliushin's avatar Vasilii Iakliushin Committed by Rémy Coutable

Change SSE route structure

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/213282

We want to migrate URIs route structure from
`gitlab.com/[namespace]/[project]/-/sse/[editable]` to
`gitlab.com/[namespace]/[project]/-/sse/[editable]/-/success`.
parent 4095185d
---
title: Add vue routes support to Static Site Editor
merge_request: 30163
author:
type: added
......@@ -31,9 +31,9 @@ scope format: false do
resources :protected_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex }
resources :protected_tags, only: [:index, :show, :create, :update, :destroy]
scope constraints: { id: /[^\0]+/ } do
scope constraints: { id: /[^\0]+?/ } do
scope controller: :static_site_editor do
get '/sse/*id', action: :show, as: :show_sse
get '/sse/:id(/*vueroute)', action: :show, as: :show_sse
end
end
end
......
......@@ -58,6 +58,11 @@ describe Projects::StaticSiteEditorController do
expect(assigns(:config)).to be_a(Gitlab::StaticSiteEditor::Config)
end
it 'correctly assigns ref and path' do
expect(assigns(:ref)).to eq('master')
expect(assigns(:path)).to eq('README.md')
end
context 'when combination of ref and file path is incorrect' do
let(:default_params) { super().merge(id: 'unknown') }
......
......@@ -822,8 +822,10 @@ describe 'project routing' do
describe Projects::StaticSiteEditorController, 'routing' do
it 'routes to static_site_editor#show', :aggregate_failures do
expect(get('/gitlab/gitlabhq/-/sse/master/CONTRIBUTING.md')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
expect(get('/gitlab/gitlabhq/-/sse/master/README')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/README')
expect(get('/gitlab/gitlabhq/-/sse/master%2FCONTRIBUTING.md')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
expect(get('/gitlab/gitlabhq/-/sse/master%2FCONTRIBUTING.md/')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
expect(get('/gitlab/gitlabhq/-/sse/master%2FREADME/unsupported/error')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/README', vueroute: 'unsupported/error')
expect(get('/gitlab/gitlabhq/-/sse/master%2Flib%2FREADME/success')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/lib/README', vueroute: 'success')
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