Commit d1f44c65 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '213282-add-support-for-vue-routes' into 'master'

Change SSE routes structure

See merge request gitlab-org/gitlab!30163
parents 6e5067d7 adce3a2c
---
title: Add vue routes support to Static Site Editor
merge_request: 30163
author:
type: added
...@@ -31,9 +31,9 @@ scope format: false do ...@@ -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_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex }
resources :protected_tags, only: [:index, :show, :create, :update, :destroy] 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 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 end
end end
......
...@@ -58,6 +58,11 @@ describe Projects::StaticSiteEditorController do ...@@ -58,6 +58,11 @@ describe Projects::StaticSiteEditorController do
expect(assigns(:config)).to be_a(Gitlab::StaticSiteEditor::Config) expect(assigns(:config)).to be_a(Gitlab::StaticSiteEditor::Config)
end 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 context 'when combination of ref and file path is incorrect' do
let(:default_params) { super().merge(id: 'unknown') } let(:default_params) { super().merge(id: 'unknown') }
......
...@@ -822,8 +822,10 @@ describe 'project routing' do ...@@ -822,8 +822,10 @@ describe 'project routing' do
describe Projects::StaticSiteEditorController, 'routing' do describe Projects::StaticSiteEditorController, 'routing' do
it 'routes to static_site_editor#show', :aggregate_failures 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%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/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%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
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